Hi there,
You have taken the bottom do/while loop out of your main() function by closing the main() function with a '}' on line 21.
Any code outside of any function (main or otherwise) or structure is considered to be "in limbo" by the compiler - it doesn't know when to call it and what to do with it.
I think you are misunderstanding the use of do/while here.
We are using do{} while (endgame == false) in order for your game to keep running without exiting on a wrong answer.
What you could do is nesting the do/while loops for every question, as such:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
do {
//question one
do {
cout << "question 1";
cin << guess;
} while (guess != 'answer');
//question two
do {
cout << "question 2";
cin << guess;
} while (guess != 'answer');
endgame = true;
} while (endgame == false);
|
In a looping structure, like do/while, the program will continue in the loop until the while expression is fulfilled, after which it just continues to the next instruction in your program. So in my example, the first do/while keeps going until endgame == true, after which there is no more instruction and the program exits. The second do/while loop will keep asking the question until the right answer is given, once it is given, it continues to the next instruction, here another do/while loop.
Hope that makes sense to you.
Small kindly remark, I noticed that you posted another topic on this, please be patient with us as we are with you.
All the best,
NwN