From f5488fb4b3315eb5596f69c17802121a7163e624 Mon Sep 17 00:00:00 2001 From: fdlt3914 Date: Mon, 6 Feb 2023 16:34:51 +0000 Subject: [PATCH] provide feedback for correct of wrong answer in hard --- src/main/quizproject.c | 45 ++++++++++++++++++++++++++++++------------ src/main/quizproject.h | 2 +- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/main/quizproject.c b/src/main/quizproject.c index e1a4793..8f3c64c 100644 --- a/src/main/quizproject.c +++ b/src/main/quizproject.c @@ -241,23 +241,37 @@ void e_math_ques() { }; char e_math_possible[][140] = { - "[A]. x = 2 [b]. x = 4 [c]. x = 5 [d]. x = 1", - "[A]. 4x^2 - 4x + 6 [b]. 4x^2 - 3x + 5 [c]. 3x^2 - 3x + 6 [d]. 4x^2 - 3x + 6", - "[A]. 1 [b]. 2 [c]. 5 [d]. 4", - "[A].y = 3x - 2. [b]. y = 2x - 1 [c]. y = 3x - 3 [d]. y = 2x - 2", - "[A]. 3x - 2. [b]. 6x + 1 [c]. 6x + 7 [d]. 2x - 2", - "[A].y = 0.5x + 8.5 [b]. y = -0.5x + 8.5 [c]. y = 0.5x - 8.5 [d]. y = -0.5x - 8.5", - "[A].x = -2 or x = -2 [b]. x = -2 or x = 2 [c]. x = 2 or x = 2 [d]. x = -1 or x = -2", - "[A]. 3x + 2. [b]. 6x + 13 [c]. 6x + 14 [d]. 2x - 2", - "[A]. (x - 3)^2 + (y - 4)^2 = 2.5 [b]. (x - 2)^2 + (y - 4)^2 = 25 [c]. (x - 3)^2 + (y - 2)^2 = 25 [d]. (x - 3)^2 + (y - 4)^2 = 25", - "[A]. x = 2 [b]. x = 6 [c]. x = 5 [d]. x = 7", + "[a]. x = 2 [b]. x = 4 [c]. x = 5 [d]. x = 1", + "[a]. 4x^2 - 4x + 6 [b]. 4x^2 - 3x + 5 [c]. 3x^2 - 3x + 6 [d]. 4x^2 - 3x + 6", + "[a]. 1 [b]. 2 [c]. 5 [d]. 4", + "[a].y = 3x - 2. [b]. y = 2x - 1 [c]. y = 3x - 3 [d]. y = 2x - 2", + "[a]. 3x - 2. [b]. 6x + 1 [c]. 6x + 7 [d]. 2x - 2", + "[a].y = 0.5x + 8.5 [b]. y = -0.5x + 8.5 [c]. y = 0.5x - 8.5 [d]. y = -0.5x - 8.5", + "[a].x = -2 or x = -2 [b]. x = -2 or x = 2 [c]. x = 2 or x = 2 [d]. x = -1 or x = -2", + "[a]. 3x + 2. [b]. 6x + 13 [c]. 6x + 14 [d]. 2x - 2", + "[a]. (x - 3)^2 + (y - 4)^2 = 2.5 [b]. (x - 2)^2 + (y - 4)^2 = 25 [c]. (x - 3)^2 + (y - 2)^2 = 25 [d]. (x - 3)^2 + (y - 4)^2 = 25", + "[a]. x = 2 [b]. x = 6 [c]. x = 5 [d]. x = 7", }; - e_math_print(e_math, e_math_possible); + char e_math_solution[11] = { + 'A', + 'D', + 'B', + 'D', + 'C', + 'B', + 'A', + 'C', + 'D', + 'B', + + }; + + e_math_print(e_math, e_math_possible, e_math_solution); } -void e_math_print(char e_ques[][140], char e_poss[][140]){ +void e_math_print(char e_ques[][140], char e_poss[][140], char e_math_solution[]){ int i = 0; @@ -267,7 +281,12 @@ void e_math_print(char e_ques[][140], char e_poss[][140]){ printf(" Answer: "); char user_answer; scanf(" %c", &user_answer); - + user_answer = toupper(user_answer); + if (user_answer == e_math_solution[i]) { + printf("Correct!\n"); + } else { + printf("Wrong!\n"); + } i++; } } diff --git a/src/main/quizproject.h b/src/main/quizproject.h index df462ab..8bb0458 100644 --- a/src/main/quizproject.h +++ b/src/main/quizproject.h @@ -43,7 +43,7 @@ int math_answer(int); void math_display_choice(); void math_enter_game(); void e_math_ques(void); -void e_math_print(char [][140], char [][140]); +void e_math_print(char [][140], char [][140], char []); void math_help(void); void math_choose_game(void);