Jump to content
  • Advertisement
Sign in to follow this  
Pharaoh12

Dont know what to use?[solved]

This topic is 4458 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to ask the user a math question and of he gets it wrong i want the user to be able to try again.Here is my code so far: #include <iostream> using namespace std; int main() { int answer; cout << "What is 9 X 2?"; cin >> answer; if (answer == 18) cout << "GREAT!"; else cout << "WRONG!"; cin.ignore(2); return 0; } So what can I add? [Edited by - Pharaoh12 on March 12, 2006 11:56:54 PM]

Share this post


Link to post
Share on other sites
Advertisement
Yeh your gonna need to use a loop. I took your code and changed it so you no what to do.


#include <iostream>
using namespace std;

int main()
{
int answer;
cout << "What is 9 X 2? ";
cin >> answer;

while(answer != 9*2)
{
cout << "\nWRONG!\n";
cout << "\nTry Again ? ";
cin >> answer;
}

cout << "\nGREAT!\n";
system("pause");

return 0;
}


Great start and good luck

Share this post


Link to post
Share on other sites
Quote:
Original post by cNoob
Yeh your gonna need to use a loop. I took your code and changed it so you no what to do.

*** Source Snippet Removed ***
Great start and good luck


Thanks for your help and i understand what you did and thanks for showing me that system("pause"); , it works well :).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!