Lecture 24 if else triplex game so far

#include

int main()

{

std::cout << "You are a Young adventurer trying to break a series of 3 digit codes to claim a priceless treasure";

std::cout << std::endl;

std::cout << "Enter the correct code to continue.....XoX" ;

// this is just declaring variables

const int CodeA = 2;

const int CodeB = 3;

const int CodeC = 5;

const int CodeSum = CodeA + CodeB + CodeC;

const int CodeProduct = CodeA * CodeB * CodeC;

/*

Now

following

the

rest to declare

*/

std::cout << std::endl;

std::cout << "-There are three lines in the code" << std::endl;

std::cout << "-The codes add up to : " << CodeSum << std::endl;

std::cout << "-The codes multiply to give: " << CodeProduct << std::endl;

int GuessA, GuessB, GuessC;



std::cout <<  " Enter Your Guess of the three digit code" << std::endl;

std::cin >> GuessA;

std::cin >> GuessB;

std::cin >> GuessC;



int GuessSum = GuessA+ GuessB+ GuessC;

int GuessProduct = GuessA* GuessB* GuessC;

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

{

    std::cout << " Gratz, You got it right ";

}

else

{

    std::cout << "You are killed by a poision Dart";

}

return 0;

}

1 Like

Great job! Make sure you post this under the Unreal section of the forum.

Hey my bad Got it will make sure i will post it there here on out

1 Like

You’re all good. Keep up the great work

Privacy & Terms