hello friends,
In this quiz code all the quiz score is counting but everytime
it shows the msg "you did ok" even after answering all answers correct
Code:
#include <stdio.h>#include <string.h>
int main(){
int rl,count,i;
int score,score1,score2,score3,score4,score5,score6;
count = 0;
for(i=0;i<=6;i++){
system("cls");
rl = i;
switch(rl){
case 1:
printf("\n\nWhich of the following is Palindrome number?");
printf("\n\nA.42042\t\tB.101010\n\nC.23232\t\tD.01234");
if(toupper(getch())=='C'){
printf("\nCorrect!!!");
count++;
score1 = 5;
getch();
break;
} else {
printf("\nWrong!!! .The correct answer is C.23232");
score1 =0;
getch();
break;
}
case 2:
printf("\n\nThe Country with highest environmental performance index is...?");
printf("\n\nA.France\t\tB.Denmark\n\nC.Switzerland\t\tD.Finland");
if(toupper(getch())=='C'){
printf("\nCorrect!!!");
count++;
score2 = 5;
getch();
break;
} else {
printf("\nWrong!!! .The correct answer is C.Switzerland");
score2 = 0;
getch();
break;
}
case 3:
printf("\n\nWhich animal laughs like human being?");
printf("\n\nA.Polar Bear\t\tB.Hyena\n\nC.Donkey\t\tD.Chimpanzee");
if(toupper(getch())=='B'){
printf("\nCorrect!!!");
count++;
score3 = 5;
getch();
break;
} else {
printf("\nWrong!!! .The correct answer is B.Hyena");
score3 = 0;
getch();
break;
}
case 4:
printf("\n\nWho was awarded the youngest player award in Fifa World Cup 2006?");
printf("\n\nA.Wayne Rooney\t\tB.Lucas Podolski\n\nC.Lionel Messi\t\tD.Christiano Ronaldo");
if(toupper(getch())=='B'){
printf("\nCorrect!!!");
score4 = 5;
count++;
getch();
break;
} else {
printf("\nWrong!!! .The correct answer is B.Lucas Podolski");
score4 = 0;
getch();
break;
}
case 5:
printf("\n\nWhich is the third highest mountain in the world?");
printf("\n\nA.Mt. K2\t\tB.Mt. Kanchanjungha\n\nC.Mt. Makalu\t\tD.Mt. Kilimanjaro");
if(toupper(getch())=='B'){
printf("\nCorrect!!!");
score5 = 5;
count++;
getch();
break;
} else {
printf("\nWrong!!! .The correct answer is B.Mt. Kanchanjungha");
score5 = 0;
getch();
break;
}
case 6:
printf("\n\nWhat is the group of frogs known as?");
printf("\n\nA.A Traffic\t\tB.A Toddler\n\nC.A Police\t\tD.An Army");
if(toupper(getch())=='D'){
printf("\nCorrect!!!");
score6 = 5;
count++;
getch();
break;
} else {
printf("\nWrong!!! .The correct answer is D.An Army");
score6 = 0;
getch();
break;
}
}//switch end
}//for loop end
if(count>=2){
printf("\nyou did ok");
score = score1+score2+score3+score4+score5+score6;
printf("\nyour total score is %d",score);
}else if (count>=4){
printf("\nyou did good");
score = score1+score2+score3+score4+score5+score6;
printf("\nyour total score is %d",score);
}else if (count==6){
printf("you are genius");
score = score1+score2+score3+score4+score5+score6;
printf("your total score is %d",score);
}else{
printf("sorry you need to practice");
}
return 0;
}