Browse Source

refactoring: proper renaming in math_display_choice

main
parent
commit
5fb7927aa3
  1. 34
      src/main/quizproject.c

34
src/main/quizproject.c

@ -190,36 +190,36 @@ int math_answer(int num1) {
}
void math_display_choice(){
int user_answer, ques_ans,repeat = 0;
int user_choice, user_answer,repeat = true;
printf("Choose a number between 1 and 4(game ends with invalid number or wrong answer): ");
scanf("%d", &user_answer);
user_answer = user_answer-1;
int quiz_answer = math_answer(user_answer);
while (user_answer != 4 || repeat) {
quiz_answer = math_answer(user_answer);
switch(user_answer){
scanf("%d", &user_choice);
user_choice = user_choice-1;
int quiz_answer = math_answer(user_choice);
while (user_choice != 4 || repeat) {
quiz_answer = math_answer(user_choice);
switch(user_choice){
case 0: case 1: case 2: case 3:
math_choose_question(user_answer);
math_choose_question(user_choice);
printf("Answer: ");
scanf("%d", &ques_ans);
repeat =1;
scanf("%d", &user_answer);
repeat =false;
break;
default:
printf("Invalid choice!\n");
}
if(quiz_answer == ques_ans){
if(quiz_answer == user_answer){
printf("Correct!\n");
} else {
printf("Wrong!\n");
break;
}
if (repeat) {
repeat = 0;
if (!(repeat)) {
repeat = true;
printf("Choose a number between 1 and 4(game ends with invalid number or wrong answer): ");
scanf("%d", &user_answer);
user_answer = user_answer-1;
scanf("%d", &user_choice);
user_choice = user_choice-1;
}
}
@ -887,9 +887,9 @@ void math_question2(){
void compare_answer(char compare, char character1){
if (compare == character1) {
score++;
printf("Right!, score is: %d\n", score);
correct(score);
} else {
printf("Wrong! score is: %d\n", score);
wrong(score);
}
}

Loading…
Cancel
Save