Question: void PrintIntroduction() { std::cout < < hello welcome again. ; std::cout < < remember to use the correct code to break the chains... ;

void PrintIntroduction() {

std::cout << " hello welcome again. ";

std::cout << "remember to use the correct code to break the chains... ";

}

bool PlayGame()

{

PrintIntroduction();

// Declare 3 point code

int CodeA = 2;

int CodeB = 3;

int CodeC = 4;

int CodeSum = CodeA + CodeB + CodeC;

int CodeProduct = CodeA * CodeB * CodeC;

std::cout << " + there are 3 numbers in the code! ";

std::cout << std::endl;

std::cout << " + the sum of the three numbers is: " << CodeSum << std::endl;

std::cout << " + the product of the numbers is: " << CodeProduct << std::endl;

std::cout << std::endl;

int GuessA, GuessB, GuessC;

std::cout << "What's your Guess? With a space between them... ";

std::cin >> GuessA;

std::cin >> GuessB;

std::cin >> GuessC;

int GuessProduct = GuessA * GuessB * GuessC;

int GuessSum = GuessA + GuessB + GuessC; if (CodeSum == GuessSum && CodeProduct == GuessProduct)

{

std::cout << "You Win!! ";

return true;

}

else

{

std::cout << " You lost ";

return false;

} }

int main()

{

while (true)

{

bool bLevelComplete = PlayGame;

std::cin.clear();

std::cin.ignore();

}

return 0;

}

I don't know why but this code takes endless time to run on VisualStudio(even after using the boolean func.). Can I know what am I doing wrong? p.s. the code is from game dev. course.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!