From b5fa325a6c4780d2f4f870e968ab790880a68229 Mon Sep 17 00:00:00 2001 From: fdlt3885 Date: Wed, 1 Feb 2023 21:47:00 +0000 Subject: [PATCH] added round 1 function and header (epic game) --- src/main/quizproject.c | 33 +++++++++++++++++++++++++++++++++ src/main/quizproject.h | 1 + 2 files changed, 34 insertions(+) diff --git a/src/main/quizproject.c b/src/main/quizproject.c index 9453e2d..3f97921 100644 --- a/src/main/quizproject.c +++ b/src/main/quizproject.c @@ -1038,6 +1038,38 @@ int B_testround(void) { return score; } +int B_round1(void) { + int score = 0; + char answer[20]; + + printf("Round 1\n"); + printf("Question 1: What is the value of x in the equation 2x + 1 = 7?\n"); + printf("Hint: Subtract 1 from both sides and then divide both sides by 2.\n"); + printf("Options: a.)1 b.)2 c.)3 d.)4 "); + printf("Answer: "); + scanf("%s", answer); + + if (strcmp(answer, "c") == 0) { + printf("Correct!\n"); + score++; + } else { + printf("Incorrect. The answer is c.\n"); + } + + printf("Question 2: What is the value of x in the equation 3x + 2 = 8?\n"); + printf("Hint: Subtract 2 from both sides and then divide both sides by 3.\n"); + printf("Options: a.)1 b.)2 c.)3 d.)4 "); + printf("Answer: "); + scanf("%s", answer); + + if (strcmp(answer, "b") == 0) { + printf("Correct!\n"); + score++; + } else { + printf("Incorrect. The answer is b.\n"); + } + return score; +} void b_epic_game() { B_displayWelcomeMessage(); @@ -1048,6 +1080,7 @@ void b_epic_game() { B_show_time(); int total_score = 0; total_score += B_testround(); + total_score += B_round1(); } diff --git a/src/main/quizproject.h b/src/main/quizproject.h index 90b937b..e9aac89 100644 --- a/src/main/quizproject.h +++ b/src/main/quizproject.h @@ -54,6 +54,7 @@ void B_userinfo(void); void B_displayGameInstructions(void); void B_show_time(void); int B_testround(void); +int B_round1(void); #define NUM_QUESTIONS 5 #define round 15