Browse Source

randomized round 4

main
fdlt3917 2 years ago
parent
commit
6f288ead0b
  1. 21
      src/main/quizproject.c

21
src/main/quizproject.c

@ -231,6 +231,16 @@ void ask_hard_questions(void) {
int k = 0; int k = 0;
while (k < 1) { 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("\t\t--------------------Round 4-------------------\n\n");
printf(">>In this round you need to answer 2 questions correctly to move to Round 5<<\n\n"); printf(">>In this round you need to answer 2 questions correctly to move to Round 5<<\n\n");
@ -247,19 +257,20 @@ void ask_hard_questions(void) {
char user_answers[NUM_QUESTIONS]; // to store user 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++) { 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++) { 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): "); printf("Enter your answer (A, B, C, or D): ");
char response; char response;
scanf(" %c", &response); scanf(" %c", &response);
response = toupper(response); response = toupper(response);
user_answers[i] = response;
user_answers[randNum] = response;
// check each answer // check each answer
if (user_answers[i] == answers[i]) {
if (user_answers[randNum] == answers[randNum]) {
score++; score++;
correct(score); correct(score);
} else { } else {

Loading…
Cancel
Save