confusion over Basic loop problem

I'm trying to build a 10 question quiz and I'm designing it to where if you get the write answer it will move to the next question.

the problem I'm having is its saying (a,b,c,d,) is not initialized to anything when I clearly have initialized it as far as I need

Why is it telling me this?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
using namespace std;

int main()
{

char Answer;
char a, b, c, d;


cout<<"you will be givin a short Exam of 10 questions \n"<<endl;
cout<<"Press enter after each question is answered \n"<<endl;
cout<<endl;
cout<<endl;
do
{
cout<<"Question 1"<<endl;
cout<<"where was Jason Born? \n\n"<<endl;
cout<<endl;
cout<<"(a) - Chicago?"<<endl;
cout<<"(b) - Atlanta?"<<endl;
cout<<"(c) - Pheonix?"<<endl;
cout<<"(d) - Tucson?" <<endl;
cin>>Answer;
cin.sync();
cin.get();

if (Answer==d)
{
cout<<"Thats Correct!"<<endl;
}
else
cout<<"Try Again"<<endl;
}while (Answer==a,b,c);



return 0;
}
try
 
while (Answer==a||Answer==b||Answer==c)
Since you are making Answer char data type, your condition for if statement must be
if(Answer=='d') but not if(Answer==d)
Last edited on
Topic archived. No new replies allowed.