Browse Source

randomized round 4

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

23
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 {

Loading…
Cancel
Save