please help me

Write a program that will ask the user a question with four possible answers.The Question should be asked 20 times.After all the input is gathered,the program should output the number of times each answer was selected??
closed account (367kGNh0)
Mate, LEARN C++.

sorry but you cannot just tell us to tell you. You wouldn't actually learn. But if you really want, here is a multiple choice quiz I made a very long time ago:


1
2
3

It is in the form of a Function so you need to learn the #include statement.

void QuizFunc()
{
int a;
char ans1;
char ans2;
char ans3;
char ans3a;
char ans3b;
char ans3c;
char ans3d;
int score = 0;




cout<< "Welcome to the quiz! What topic of questions would you like? (type in a number)\n1)People \n2)Geography\n3)Numbers\n";
cin>> a;
if (a == 1){
cout<< "Question 1:\n Who was the first man on the Moon?(Type in the letter)\na.Buzz Aldrin\nb.Neil Aldrin\nc.Neil Armstrong\n";
cin>> ans1;
switch (ans1) {

case 'a': cout<<"Incorrect!";
break;
case 'b': cout<<"Incorrect!";
break;
case 'c': cout<<"Correct!";
break;

default: cout<<"That isn't a valid answer";
}}

if (a == 2){
cout<< "Question 1:\n What country is Caracas, a capital city, in?(Type in the letter)\n"
<<"a. Congo\n"
<<"b. Venuzuela\n"
<<"c. Laos";
cin>> ans2;
switch (ans2) {

case 'a': cout<<"Incorrect";
break;
case 'b': cout<<"correct!";
break;
case 'c': cout<<"Incorrect";
break;

default: cout<<"That isn't a valid answer";
}}


if (a ==3){
cout<< "Question 1:What is 9 x 12?(Type in the number)\na.104\nb.185\nc.108\n";
cin >> ans3;
switch (ans3) {

case 'a': cout<<"Incorrect\n";
break;
case 'b': cout<<"Incorrect\n";
break;
case 'c': cout<<"Correct!\n";
score+=1;
break;

default: cout<<"That isn't a valid answer";
}}

cout<< "Question 2:What is 6 x 7?(Type in the letter)\na.42\nb.85\nc.49\n";
cin >> ans3a;
if (ans3a == 'a')
{cout<<"Thats correct\n";

score += 1;
}
Last edited on
Hello Mehmood Umer,

In preparation for the future and do not take this the wrong way as it is a copy and paste.


PLEASE ALWAYS USE CODE TAGS (the <> formatting button), to the right of this box, when posting code.

It makes it easier to read your code and also easier to respond to your post.

http://www.cplusplus.com/articles/jEywvCM9/
http://www.cplusplus.com/articles/z13hAqkS/

Hint: You can edit your post, highlight your code and press the <> formatting button.
You can use the preview button at the bottom to see how it looks.

I found the second link to be the most help.


It is the links that are important.

Start by writing a program that will display the question, the four choices and get the user's choice. From this you can build on the rest of what you need, but you do need a starting point.

Post the code you come up with and you can get better suggestions on what to do.

If you have no idea what to do say so. You might want to look at: http://www.cplusplus.com/doc/tutorial/ for a place to start.

Write some code and post it. In the mean time I will see what I can come up with.

Hope that helps,

Andy
closed account (367kGNh0)
handy andy did you mean me?
@Rascake,

Not directly, but if the shoe fits, wear it.

And if I meant you I would have said so.
Last edited on
Topic archived. No new replies allowed.