|
@ -172,7 +172,7 @@ void timequiz() { |
|
|
printf("\nQuiz finished!\n"); |
|
|
printf("\nQuiz finished!\n"); |
|
|
printf("Your total score: %d out of %d\n", totalCorrectAnswers, totalAnsweredQuestions); |
|
|
printf("Your total score: %d out of %d\n", totalCorrectAnswers, totalAnsweredQuestions); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Zufällige Frage auswählen |
|
|
int getRandomQuestionIndex(int askedQuestions[], int totalQuestions) { |
|
|
int getRandomQuestionIndex(int askedQuestions[], int totalQuestions) { |
|
|
int questionIndex; |
|
|
int questionIndex; |
|
|
do { |
|
|
do { |
|
@ -180,14 +180,14 @@ int getRandomQuestionIndex(int askedQuestions[], int totalQuestions) { |
|
|
} while (askedQuestions[questionIndex] == 1); |
|
|
} while (askedQuestions[questionIndex] == 1); |
|
|
return questionIndex; |
|
|
return questionIndex; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Frage anzeigen |
|
|
void displayQuestion(char* question, char* answers[], int correctIndex) { |
|
|
void displayQuestion(char* question, char* answers[], int correctIndex) { |
|
|
printf("\nQuestion: %s\n", question); |
|
|
printf("\nQuestion: %s\n", question); |
|
|
for (int i = 0; i < 4; i++) { |
|
|
for (int i = 0; i < 4; i++) { |
|
|
printf("%d. %s\n", i + 1, answers[i]); |
|
|
printf("%d. %s\n", i + 1, answers[i]); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//User-Eingabe Verarbeitung |
|
|
void processUserAnswer(int userAnswer, int correctIndex, int* score, int* totalCorrectAnswers, char* answers[]) { |
|
|
void processUserAnswer(int userAnswer, int correctIndex, int* score, int* totalCorrectAnswers, char* answers[]) { |
|
|
if (userAnswer == correctIndex + 1) { |
|
|
if (userAnswer == correctIndex + 1) { |
|
|
printf("Correct!\n"); |
|
|
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]); |
|
|
printf("Wrong! The correct answer is: %d. %s\n", correctIndex + 1, answers[correctIndex]); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Prüfung auf gültige Antwort |
|
|
int isValidAnswer(int userAnswer) { |
|
|
int isValidAnswer(int userAnswer) { |
|
|
return (userAnswer >= 1 && userAnswer <= 4); |
|
|
return (userAnswer >= 1 && userAnswer <= 4); |
|
|
} |
|
|
} |