So I put my while loop here at the challenge and it worked fine, just wondering why that is and why its better to put it in the main function?
void PlayGame()
{
// delcare 3 number code
const int CodeA = 1;
const int CodeB = 0;
const int CodeC = 7;
const int CodeSum = CodeA + CodeB + CodeC;
const int CodeProduct = CodeA * CodeB * CodeC;
//Print CodeSum and CodeProduct to the terminal
std::cout << "\n The code to disarm the bomb has 3 digits.";
std::cout << "\n The codes add-up to: " << CodeSum;
std::cout << "\n The digits multiply makes: " << CodeProduct << std::endl;
//Store player guess
int GuessA, GuessB, GuessC;
std::cin >> GuessA >> GuessB >> GuessC;
int GuessSum = GuessA + GuessB + GuessC;
int GuessProduct = GuessA * GuessB * GuessC;
//Check if player Guess is correct
if(GuessSum == CodeSum && GuessProduct == CodeProduct)
{
std::cout<<"\nYou Have Disarmed the bomb!";
}
else
{
std::cout<<"\nYou blew up!";
}
while(PlayGame)
{
PlayGame();
}
}
int main()
{
PrintIntroduction();
PlayGame();
return 0;
}