From f2cf4042da554fa62d5535b03e15911d627f044b Mon Sep 17 00:00:00 2001 From: fdlt3859 Date: Mon, 30 Jan 2023 15:09:45 +0000 Subject: [PATCH] Started Fact or Lie quiz --- src/main/quizproject.c | 28 +++++++++++++++++++++++++++- src/main/quizproject.h | 1 + 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/main/quizproject.c b/src/main/quizproject.c index 587c856..acb774e 100644 --- a/src/main/quizproject.c +++ b/src/main/quizproject.c @@ -437,9 +437,35 @@ if (score > 2){ displayThankYouMessage(); } +void v_factorlie(void){ + char statements[][100] = { + "Tomatoes are fruits.", // lie + + }; + char answers[] = {'L'}; // L for lie, F for fact + int num_statements = sizeof(statements) / sizeof(statements[0]); + int score = 0; + + for (int i = 0; i < num_statements; i++) { + char user_answer; + printf("Statement %d: %s\n\n", i + 1, statements[i]); + printf("Is this statement a fact (F) or a lie (L)?\n"); + printf("Your answer: \n"); + scanf(" %c", &user_answer); + if (user_answer == answers[i]) { + score++; + printf("Correct!\n"); + } else { + printf("Incorrect.\n"); + } + } + printf("Your final score is %d out of %d.\n", score, num_statements); + +} + void play_factorlie() { printf("Playing game 2...\n"); - // code for game 2 goes here + v_factorlie(); } void play_milliongame() { diff --git a/src/main/quizproject.h b/src/main/quizproject.h index 02f5b3f..742ba1c 100644 --- a/src/main/quizproject.h +++ b/src/main/quizproject.h @@ -23,6 +23,7 @@ int* randomNumber(); void hintForHardQuestions(int); void feedbackForm(void); void displayCredits(void); +void v_factorlie(void); #define NUM_QUESTIONS 5 #define round 3