From 6f288ead0ba78ece70d37d3d612242a9e1c173a4 Mon Sep 17 00:00:00 2001 From: fdlt3917 Date: Thu, 26 Jan 2023 10:38:56 +0000 Subject: [PATCH] randomized round 4 --- src/main/quizproject.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/main/quizproject.c b/src/main/quizproject.c index d54cdd2..da442af 100644 --- a/src/main/quizproject.c +++ b/src/main/quizproject.c @@ -231,6 +231,16 @@ void ask_hard_questions(void) { int k = 0; while (k < 1) { + int *lessFive = randomNumber(); + int arr[5]; + int p = 0; + for(int i = 0; i < 8; i++){ + if(lessFive[i] < 2){ + arr[p] = lessFive[i]; + p++; + } + } + printf("\t\t--------------------Round 4-------------------\n\n"); printf(">>In this round you need to answer 2 questions correctly to move to Round 5<<\n\n"); @@ -246,20 +256,21 @@ void ask_hard_questions(void) { char answers[NUM_QUESTIONS] = { 'B', 'A'}; // correct answers (A, B, C, or D) char user_answers[NUM_QUESTIONS]; // to store user answers (A, B, C, or D) - + + int randNum; for (int i = 0; i < 2; i++) { - - printf("[%d] %s\n", i + 1, questions[i]); + randNum = arr[i]; + printf("[%d] %s\n", i + 1, questions[randNum]); for (int j = 0; j < 4; j++) { - printf("%s\n", options[i][j]); + printf("%s\n", options[randNum][j]); } printf("Enter your answer (A, B, C, or D): "); char response; scanf(" %c", &response); response = toupper(response); - user_answers[i] = response; + user_answers[randNum] = response; // check each answer - if (user_answers[i] == answers[i]) { + if (user_answers[randNum] == answers[randNum]) { score++; correct(score); } else {