From f38f4a9de0e2c7e644a3f6223b81c6892a005b97 Mon Sep 17 00:00:00 2001 From: Pascal Schneider Date: Tue, 6 Feb 2024 21:22:41 +0100 Subject: [PATCH] =?UTF-8?q?refactoring:=20Kommentare=20f=C3=BCr=20Funktion?= =?UTF-8?q?en=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/timequiz.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/timequiz.c b/src/timequiz.c index bf8eaec..37cdc0c 100644 --- a/src/timequiz.c +++ b/src/timequiz.c @@ -172,7 +172,7 @@ void timequiz() { printf("\nQuiz finished!\n"); printf("Your total score: %d out of %d\n", totalCorrectAnswers, totalAnsweredQuestions); } - +//Zufällige Frage auswählen int getRandomQuestionIndex(int askedQuestions[], int totalQuestions) { int questionIndex; do { @@ -180,14 +180,14 @@ int getRandomQuestionIndex(int askedQuestions[], int totalQuestions) { } while (askedQuestions[questionIndex] == 1); return questionIndex; } - +//Frage anzeigen void displayQuestion(char* question, char* answers[], int correctIndex) { printf("\nQuestion: %s\n", question); for (int i = 0; i < 4; i++) { printf("%d. %s\n", i + 1, answers[i]); } } - +//User-Eingabe Verarbeitung void processUserAnswer(int userAnswer, int correctIndex, int* score, int* totalCorrectAnswers, char* answers[]) { if (userAnswer == correctIndex + 1) { printf("Correct!\n"); @@ -198,7 +198,7 @@ void processUserAnswer(int userAnswer, int correctIndex, int* score, int* totalC printf("Wrong! The correct answer is: %d. %s\n", correctIndex + 1, answers[correctIndex]); } } - +//Prüfung auf gültige Antwort int isValidAnswer(int userAnswer) { return (userAnswer >= 1 && userAnswer <= 4); }