Browse Source

Math quiz:display of questions and choice

main
parent
commit
0f394a2fa6
  1. 50
      src/main/quizproject.c
  2. 11
      src/main/quizproject.h

50
src/main/quizproject.c

@ -28,6 +28,49 @@ int* randomNumber() {
} }
//------------Math_quiz_begin------------
void math_choose_question(int num) {
char choose [][100] = {
"what is 1 + 1\n",
"what is 4 + 3\n",
"what is 4 * 8\n",
"what is ((6*8)/4)+2\n"
};
printf("%s", choose[num]);
}
int math_answer(int num1) {
int ans[]= {
2,
7,
32,
14
};
return ans[num1];
}
void math_display_choice(){
int user_answer;
for(int i = 0; i < 4; i++){
math_choose_question(i);
printf("Answer: ");
scanf("%d", &user_answer);
int quiz_answer = math_answer(i);
if(quiz_answer == user_answer){
printf("Correct!\n");
} else {
printf("Wrong!\n");
}
}
}
//------------Math_quiz_end--------------
//-------smart_brain_quiz_begin---------- //-------smart_brain_quiz_begin----------
void e_press_key_start() { void e_press_key_start() {
@ -1977,7 +2020,8 @@ int main(int argc, char *argv[]) {
printf("6. Smart Brain\n"); printf("6. Smart Brain\n");
printf("7. Epic Game\n"); printf("7. Epic Game\n");
printf("8. Rock,Paper,Scissors!\n"); printf("8. Rock,Paper,Scissors!\n");
printf("9. Exit\n");
printf("9. Math Quiz\n");
printf("10. Exit\n");
printf("Enter your choice: "); printf("Enter your choice: ");
scanf("%d", &choice); scanf("%d", &choice);
v_progress_bar(argc,argv); v_progress_bar(argc,argv);
@ -2016,6 +2060,10 @@ int main(int argc, char *argv[]) {
jump_to_menu = 1; jump_to_menu = 1;
break; break;
case 9: case 9:
math_display_choice();
jump_to_menu = 1;
break;
case 10:
printf("\nThank you for trying our C code!\n"); printf("\nThank you for trying our C code!\n");
break; break;
default: default:

11
src/main/quizproject.h

@ -36,6 +36,17 @@ void million_instructions();
void million_exit(int million_a); void million_exit(int million_a);
//------Math_quiz_header_begin-----
void math_choose_question(int);
int math_answer(int);
void math_display_choice();
//------Math_quiz_header_end-------
//----smart_brain_header_begin----- //----smart_brain_header_begin-----
void e_press_key_start(void); void e_press_key_start(void);

Loading…
Cancel
Save