Math Game help

hey guys, i kinda need some help with a project,i seem to have most of it down but i cant seem to make the program run until the user uses all of its 3 tries, thank you:)
heres what i have so far....

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main ()

{
int num1;
int num2;
int ans;
int score = 0;
bool done;
int noOfGuesses;


num1 = rand() % 30;
num2 = rand() % 25;

done = false;
noOfGuesses = 0;

while ((noOfGuesses < 3) && (!done))
{
cout << "Welcome to Fun Math 101 :) We wiil play "
<< "a game where you will be asked math problems,"
<< "if you answer right you can go on to the next question"
<< ",you have 3 tries or your out.";

cout << endl;
noOfGuesses++;

{
cout <<"What is"<< num1 <<"+" << num2 <<"?";
cin >>ans;

if (ans == num1 + num2)
{
cout << "Correct answer:)";
score +=1;
cout << "Your score is " << score << endl << endl;
done = true;
break;
}

else
{
cout << "Wrong answer" << endl << endl;
}


if (noOfGuesses != 3 && !done)
{
cout << "Please try again" << endl << endl;
}

}
}
if (!done)
cout << "Game over:/ Right Answer is" << ans << endl << endl;

}
Last edited on
Please re-email me at cosmin.p@live.com and explain what your program make, i will re make the code. Please remember i go to church and i will be back in something like 30-60 mins.
Topic archived. No new replies allowed.