From 89ddc769dcd0ac5795b4aea8e7697a0327f527e2 Mon Sep 17 00:00:00 2001 From: Pascal Schneider Date: Mon, 5 Feb 2024 23:51:29 +0100 Subject: [PATCH] =?UTF-8?q?Funktion=20f=C3=BCr=20Antwort=20und=20Score=20v?= =?UTF-8?q?2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/timequiz.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/timequiz.c b/src/timequiz.c index 9c87e94..c7bb333 100644 --- a/src/timequiz.c +++ b/src/timequiz.c @@ -89,4 +89,12 @@ void displayQuestion(char* question, char* answers[], int correctIndex) { } void processUserAnswer(int userAnswer, int correctIndex, int* score, int* totalCorrectAnswers, char* answers[]) { + if (userAnswer == correctIndex + 1) { + printf("Correct!\n"); + (*score)++; + (*totalCorrectAnswers)++; + } + else { + printf("Wrong! The correct answer is: %d. %s\n", correctIndex + 1, answers[correctIndex]); + } }