Answer to Question #30846 in C++ for Sarah

Question #30846
Write a program showing how to assign multiple choice answers to a question that is being randomized. ( survey type program therefore no wrong answers)
1
Expert's answer
2013-05-21T08:06:12-0400
#include <iostream>#include <stdlib>
using namespace;
int number, answer;
int main()
{
number=rand()%3+1;
if (number==1){
cout<<"What the capital of GB? 1. London, 2. Berlin, 3.Amsterdam"<<endl;
cin>>answer;
if(answer==1) cout<<"True";
elsecout<<"False";
}
else if(number==2){
cout<<"What the capital of Germany? 1. London, 2. Berlin, 3.Amsterdam"<<endl;
cin>>answer;
if(answer==2) cout<<"True";
elsecout<<"False";
}
else if(number==1){
cout<<"What the capital of USA? 1. Washington, 2. Berlin, 3.Amsterdam"<<endl;
cin>>answer;
if(answer==1) cout<<"True";
elsecout<<"False";
}
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS