how to end my while loop

// i already done my program but it should say congratulations at the end after users answer correctly all the questions.

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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
string A,animal,correct,heading,A1,answer1,name;
int age,subject;
string subj[10] = {"[1] Grade 1 Civics and culture" ,  "[2] Grade 1 Filipino", "[3] Grade 2 English","[4] Grade 2 Math", "[5] Grade 3 Civics and Culture", "[6] Grade 3 Math", "[7] Grade 4 History", "[8] Grade 4 MAPEH" , "[9] Grade 5 Science", "[10] Grade 5 English"};
char play,another,N,n,Y,y,ans,g,G,I,i,X,x,C1,help;
  while(A1==correct){
system("cls");
cout << "====================================================" << endl;                   
cout << "Are you smarter than a 5th grader?" << endl; 
cout << "====================================================\n\n\n" << endl; 

//cout<<" [1] Grade 1 Civics and Culture [2] Grade 1 Filipino\n\n [3] Grade 2 English\t\t [4] Grade 2 Math\n\n [5] Grade 3 Civics and Culture [6] Grade 3 Math\n\n [7] Grade 4 History\t\t [8] Grade 4 MAPEH\n\n [9] Grade 5 Science\t\t [10] Grade 5 English\n\n";
for(int ctr = 0;  ctr<10; ctr++)
{
	cout<<subj[ctr]<<endl;
}
cout<<"\nPlease select your subject: ";
cin>>subject;
system("cls");
switch(subject){
case 1: cout << "====================================================" << endl;                   
cout << "Are you smarter than a 5th grader?" << endl; 
cout << "====================================================\n\n\n" << endl; 
cout<<"Complete the quote below:\n\n"; //answer dito ay: animal
cout<<" He who does not love his own language is worse than an _____ and smelly fish\n\n";
cout<<"Do you need help?[y/n]: ";
cin>>help;
subj[0] = "";
if(help=='Y'||help=='y'){
if (peekUsed == false)
cout << "[P] for peek\n";
if (copyUsed == false)
cout << "[C] for Copy\n";
if(saveUsed == false)
cout<<"[S] for Save\n";
cout<<"Enter your choice: ";
cin>>C1;
{
if(C1=='P'||C1=='p'){
cout<<"\nThe answer is animal";
peekUsed=true;
cout<<"\n\nEnter your answer: ";
cin>>A1;
correct="animal";
{
if(A1==correct)
cout<<"Correct!";

if(A1!=correct)
cout<<"Wrong answer";

}
}
if(C1=='C'||C1=='c'){
cout<<"Correct! The answer is animal ";
copyUsed=true;
}
if(C1=='S'||C1=='s'){
cout<<"Enter your answer: ";
cin>>A;
cout<<"Correct! The answer is animal";
saveUsed=true;
}
}
}
if(help=='N'||help=='n'){
cout<<"Enter your answer: ";
cin>>A1;
correct="animal";
{
if(A1==correct)
cout<<"Correct!";

if(A1!=correct)
cout<<"Wrong answer";

}
}

break;
case 2: cout << "====================================================" << endl;                   
cout << "Are you smarter than a 5th grader?" << endl; 
cout << "====================================================\n\n\n" << endl; 
cout<<"A part of a friendly letter where it states the adress of the writer and the date it was made\n\n"; //answer dito ay heading
cout<<"Do you need help?[y/n]: ";
cin>>help;
subj[1] = "";
if(help=='Y'||help=='y'){
if (peekUsed == false)
cout << "[P] for peek\n";
if (copyUsed == false)
cout << "[C] for Copy\n";
if(saveUsed == false)
cout<<"[S] for Save\n";
cout<<"Enter your choice: ";
cin>>C1;
{
if(C1=='P'||C1=='p'){
cout<<"The answer is heading";
peekUsed=true;
cout<<"\nEnter your answer: ";
cin>>A1;
correct="heading";
{
if(A1==correct)
cout<<"Correct!";

if(A1!=correct)
cout<<"Wrong answer";

}
}
if(C1=='C'||C1=='c'){
cout<<"Correct! The answer is heading ";
copyUsed=true;
}
if(C1=='S'||C1=='s'){
cout<<"Enter your answer: ";
cin>>A;
cout<<"Correct! The answer is heading";
saveUsed=true;
}
}
}
if(help=='N'||help=='n'){
cout<<"Enter your answer: ";
cin>>A1;
correct="heading";
{
if(A1==correct)
cout<<"Correct!";

if(A1!=correct)
cout<<"Wrong answer";

}
}
break;
case 3: cout << "====================================================" << endl;                   
cout << "Are you smarter than a 5th grader?" << endl; 
cout << "====================================================\n\n\n" << endl; 
cout<<"True or False:\n\n"; //answer dito ay true
cout<<"When the plural of a noun shows possession or ownership, it is in its plural possessive form\n\n";
cout<<"Do you need help?[y/n]: ";
cin>>help;
subj[2] = "";
if(help=='Y'||help=='y'){
if (peekUsed == false)
cout << "[P] for peek\n";
if (copyUsed == false)
cout << "[C] for Copy\n";
if(saveUsed == false)
cout<<"[S] for Save\n";
cout<<"Enter your choice: ";
cin>>C1;
{
if(C1=='P'||C1=='p'){
cout<<"The answer is true";
peekUsed=true;
cout<<"\nEnter your answer: ";
cin>>A1;
correct="true";
{
if(A1==correct)
cout<<"Correct!";

if(A1!=correct)
cout<<"Wrong answer";

}
}
if(C1=='C'||C1=='c'){
cout<<"Correct! The answer is true ";
copyUsed=true;
}
if(C1=='S'||C1=='s'){
cout<<"Enter your answer: ";
cin>>A;
cout<<"Correct! The answer is true";
saveUsed=true;
}
}
}
if(help=='N'||help=='n'){
cout<<"Enter your answer: ";
cin>>A1;
correct="true";
{
if(A1==correct)
cout<<"Correct!";

if(A1!=correct)
cout<<"Wrong answer";

}
}
break;
I don't see "congratulations" anywhere in your code.
closed account (48T7M4Gy)
it should say congratulations at the end after users answer correctly all the questions


Do it in steps:
1. Score each test question
2. Add up the scores
3. Work out where/when the test is complete
4. Assess the total score and whether it is 100%
5. If the total score is 100% then display "Congratulations"

Who knows what happens if the total is less than 100% ?
Topic archived. No new replies allowed.