Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <conio.h>
- const int ALLQUESTION = 10;
- const int ALLCHOICE = 3;
- const int CORRECTSCORE = 4;
- const char* question[ALLQUESTION] = {
- "question1",
- "question2",
- "question3",
- "question4",
- "question5",
- "question6",
- "question7",
- "question8",
- "question9",
- "question10",
- };
- const char* choice[ALLQUESTION][ALLCHOICE] = {
- {"choice1 q1" , "choice2 q1" , "choice3 q1" },
- {"choice1 q2" , "choice2 q2" , "choice3 q2" },
- {"choice1 q3" , "choice2 q3" , "choice3 q3" },
- {"choice1 q4" , "choice2 q4" , "choice3 q4" },
- {"choice1 q5" , "choice2 q5" , "choice3 q5" },
- {"choice1 q6" , "choice2 q6" , "choice3 q6" },
- {"choice1 q7" , "choice2 q7" , "choice3 q7" },
- {"choice1 q8" , "choice2 q8" , "choice3 q8" },
- {"choice1 q9" , "choice2 q9" , "choice3 q9" },
- {"choice1 q10" , "choice2 q10" , "choice3 q10" }
- };
- const int answer[ALLQUESTION] = {1, 2, 3, 2, 1, 2, 3, 2, 1, 2};
- int main(){
- int myscore = 0, ch;
- printf("Quiz game\n");
- printf("Welcome\n\n");
- printf("There are %d question for you.\n", ALLQUESTION);
- printf("Please enter in form '1','2' and '3' only\n");
- for(int i = 0; i < ALLQUESTION; ++i){
- printf("\n%d. %s\n", i + 1, question[i]);
- for(int j = 0; j < ALLCHOICE; ++j)
- printf(" (%d) %s\n", j + 1, choice[i][j]);
- printf("Enter your choice: "); scanf("%d", &ch);
- printf("\n");
- if(ch == answer[i]){
- myscore += CORRECTSCORE;
- printf("well done\n");
- }else printf("sorry wrong answer\n");
- printf("Your score is %d\n", myscore);
- getch();
- system("cls");
- }
- printf("\nYour total score is %d\n", myscore);
- printf("Equal to %d percent.\n\n", (myscore * 100) / (CORRECTSCORE * ALLQUESTION));
- if(myscore >= 52) printf("You are cheating.\n");
- else if(myscore >= 28) printf("Well done\n");
- else if(myscore >= 16) printf("So_so\n");
- else if(myscore >= 4) printf("Idiot\n");
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement