I have made my code interactive for the first time!

This is pretty basic stuff i imagine. I am however, pretty chuffed with myself. Check it out:


int main()


// Print welcome messages to the terminal

std:: cout << "You are a thief attempting to gain access to the Wizard's Tower in order to steal the dark secrets from within.";

std:: cout << std::endl;

std:: cout << "There are no keyholes. In order to gain access you must correctly enter a mysterious runic code for each door..." << std::endl;

//Declare 3 number code

const int CodeA = 4;

const int CodeB = 2;

const int CodeC = 3;

const int CodeSum = CodeA + CodeB + CodeC;

const int CodeProduct = CodeA * CodeB * CodeC;

//Print CodeSum and CodeProduct to the terminal

std::cout << std::endl;

std::cout << "+ There are 3 numbers YOU must enter for the code" <<std::endl;

std::cout << "+ The correct numbers in the code add up to: " << CodeSum << std::endl;

std::cout << "+ The correct code numbers also multiply to give: " << CodeProduct << std:: endl;

int GuessA, GuessB, GuessC;

std::cin >>GuessA;

std::cin >>GuessB;

std::cin >>GuessC;

std::cout << "You entered: " << GuessA << GuessB << GuessC;

int GuessSum = GuessA + GuessB + GuessC;

int GuessProduct = GuessA * GuessB * GuessC;

std::cout << std::endl;

if(GuessSum == CodeSum && GuessProduct == CodeProduct)


    std::cout << "You've cracked the code! You progress further into the depths of the Wizard's Tower";




    std::cout << "You hear a distant cackling. You look skywards, molten coals pour down onto you from above ... You are dead.";


return 0;


1 Like

It’s really good code! Awesome job! You now have the tools to program.

Privacy & Terms