Why not make this code simpler?

int main()
{
PrintIntro();
do
{
PlayGame();
} while (AskToPlayAgain());

return 0;

}

You can do it this way. This is just another way for it. So you do not have to place the bool value in a variable. (You would want to put it in a variable if it will be used in other places… possibly).

If the Intro is very long, it might be desirable to omit repetitions, but then the user has to go look for it.

Another reason for PrintIntro() in the do-while is that things may change (e.g., the number of letters in the secret word). That’s all for the future though.

Until we have more for the intro, repeating the short intro is no problem. It is your choice as the designer, though.

This topic is about the omission of the bPlayAgain variable.

I agree, I came to a similar solution, although I repeated the intro. I think yours is much clearer to understand. However, there may be a reason in future lessons.

Here is what I came up with:

Privacy & Terms