Advertisement
nullzero

Pawpraew game

Aug 28th, 2012
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.28 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <conio.h>
  4.  
  5. const int ALLQUESTION   = 10;
  6. const int ALLCHOICE     = 3;
  7. const int CORRECTSCORE  = 4;
  8.  
  9. const char* question[ALLQUESTION] = {
  10.     "question1",
  11.     "question2",
  12.     "question3",
  13.     "question4",
  14.     "question5",
  15.     "question6",
  16.     "question7",
  17.     "question8",
  18.     "question9",
  19.     "question10",
  20. };
  21.  
  22. const char* choice[ALLQUESTION][ALLCHOICE] = {
  23.     {"choice1 q1"   ,  "choice2 q1"     ,   "choice3 q1"    },
  24.     {"choice1 q2"   ,  "choice2 q2"     ,   "choice3 q2"    },
  25.     {"choice1 q3"   ,  "choice2 q3"     ,   "choice3 q3"    },
  26.     {"choice1 q4"   ,  "choice2 q4"     ,   "choice3 q4"    },
  27.     {"choice1 q5"   ,  "choice2 q5"     ,   "choice3 q5"    },
  28.     {"choice1 q6"   ,  "choice2 q6"     ,   "choice3 q6"    },
  29.     {"choice1 q7"   ,  "choice2 q7"     ,   "choice3 q7"    },
  30.     {"choice1 q8"   ,  "choice2 q8"     ,   "choice3 q8"    },
  31.     {"choice1 q9"   ,  "choice2 q9"     ,   "choice3 q9"    },
  32.     {"choice1 q10"  ,  "choice2 q10"    ,   "choice3 q10"   }
  33. };
  34.  
  35. const int answer[ALLQUESTION] = {1, 2, 3, 2, 1, 2, 3, 2, 1, 2};
  36.  
  37. int main(){
  38.     int myscore = 0, ch;
  39.     printf("Quiz game\n");
  40.     printf("Welcome\n\n");
  41.     printf("There are %d question for you.\n", ALLQUESTION);
  42.     printf("Please enter in form '1','2' and '3' only\n");
  43.    
  44.     for(int i = 0; i < ALLQUESTION; ++i){
  45.         printf("\n%d. %s\n", i + 1, question[i]);
  46.         for(int j = 0; j < ALLCHOICE; ++j)
  47.             printf(" (%d) %s\n", j + 1, choice[i][j]);
  48.            
  49.         printf("Enter your choice: "); scanf("%d", &ch);
  50.        
  51.         printf("\n");
  52.         if(ch == answer[i]){
  53.             myscore += CORRECTSCORE;
  54.             printf("well done\n");
  55.         }else printf("sorry wrong answer\n");
  56.        
  57.         printf("Your score is %d\n", myscore);
  58.        
  59.         getch();
  60.         system("cls");
  61.     }
  62.    
  63.     printf("\nYour total score is %d\n", myscore);
  64.     printf("Equal to %d percent.\n\n", (myscore * 100) / (CORRECTSCORE * ALLQUESTION));
  65.    
  66.    
  67.     if(myscore >= 52) printf("You are cheating.\n");
  68.     else if(myscore >= 28) printf("Well done\n");
  69.     else if(myscore >= 16) printf("So_so\n");
  70.     else if(myscore >= 4) printf("Idiot\n");
  71.     getch();
  72.     return 0;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement