# help

Page 1 of 1

## 2 Replies - 330 Views - Last Post: 19 April 2013 - 11:18 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=319035&amp;s=4b5c8dab6c1d7bb6ea7a4f31bf58e494&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 makeitloud

• D.I.C Head

Reputation: 0
• Posts: 64
• Joined: 08-April 13

# help

Posted 19 April 2013 - 10:03 PM

```#include <iostream>
#include <string>
#include <ctime>
using namespace std;

int main()
{
srand (time(NULL));

int grade, operands[2], userAnswer;

string quiz, name;

char answer, again;

cout << "What is your name?\n";
cin >> name;
cout << "Were going to take a quiz, are you ready? <y/n>\n";
cin >> answer;
if(answer == 'y' || answer == 'Y')
{
cout << "Ok lets get started " << name << endl;
cout << "First lets do a math problem.\n";
operands[0] = rand()%50;
operands[1] = rand()%20;

cout << "What is " << operands[0] << " + " << operands[1] << " ?\n";
cin >> userAnswer;
if(userAnswer==operands[0] + operands[1])
{
cout << "You got the Problem right, off to the next question\n";
}
else
{
cout << "Problem incorrect\n";
cout << "Would you like to try again?\n";
cin >> again;
}

}

system("pause");
return 0;
}
```

i wanna make it so when you get the answer wrong itll ask the question again. how would i go about to do that, a person told me to use a do while loop but i dont no how i would put that in.

Is This A Good Question/Topic? 0

## Replies To: help

### #2 Martyr2

• Programming Theoretician

Reputation: 5186
• Posts: 13,914
• Joined: 18-April 07

## Re: help

Posted 19 April 2013 - 11:16 PM

Follow the pseudocode...

```Ask user for input
Collect answer

while test for answer bad
ask for input
collect answer
end while

process answer as normal

```

Was This Post Helpful? 0

### #3 macosxnerd101

• Games, Graphs, and Auctions

Reputation: 12273
• Posts: 45,364
• Joined: 27-December 08

## Re: help

Posted 19 April 2013 - 11:18 PM

You've already asked this on your existing thread. Also, please use a descriptive title for your threads.
Was This Post Helpful? 0

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }