OK, just to let everyone know, I am sort of new to programming. I am making a quiz program, and I need a loop (I dont know which kind). I am trying to make it so that if I get a wrong answer it will repeat the question. I will post an example of the code below.
int question;
cout <<"\nWhat is the word that means to break away?: \n";
cout <<"1 - Unite\n";
cout <<"2 - Secede\n";
cout <<"Pick your question: ";
cin >>question;
switch (question)
{
case 1:
cout <<"WRONG!!.\n";
break;
case 2:
cout <<"CORRECT!!.\n";
break;
default:
cout <<"Error - Invalid input; only 1 or 2 allowed.\n";
}
If anyone could help it would be greatly appreciated. THANKS.
do
{
cout <<"\nWhat is the word that means to break away?: \n";
cout <<"1 - Unite\n";
cout <<"2 - Secede\n";
cout <<"Pick your question: ";
cin >>question;
switch (question)
{
case 1:
cout <<"WRONG!!.\n";
break;
case 2:
cout <<"CORRECT!!.\n";
break;
default:
cout <<"Error - Invalid input; only 1 or 2 allowed.\n";
}
} while ( question != 1 && question != 2 );