From 672314d01a38920e1130cfa3e49ffb4e2b2d2863 Mon Sep 17 00:00:00 2001 From: fdlt3917 Date: Wed, 25 Jan 2023 10:12:44 +0000 Subject: [PATCH] added printoutoption function --- src/main/quizproject.c | 96 ++++++++++++------------------------------ src/main/quizproject.h | 1 + 2 files changed, 27 insertions(+), 70 deletions(-) diff --git a/src/main/quizproject.c b/src/main/quizproject.c index f9ee65d..d59b6de 100644 --- a/src/main/quizproject.c +++ b/src/main/quizproject.c @@ -78,14 +78,8 @@ void fifty_fifty(int question_num) { }; printf("%s\n",qC[question_num]); } - -void looping(char qS[][100], char qC[][100], char aS[]){ - -int k = 0; - while(k < 1){ - printf("\t\t--------------------Round 1-------------------\n\n"); - printf(">>In this round you need to answer 3 questions correctly to move to Round 2<<\n\n"); - char response; +void printOutOption(char qS[][100], char qC[][100],char aS[]){ + char response; for (int i = 0; i < 1; i++){ printf("%s\n", qS[i]); printf("%s\n", qC[i]); @@ -108,87 +102,49 @@ int k = 0; if(response == aS[i]){ score++; - correct(score); - + correct(score); + fact(i); } else { - wrong(score); + wrong(score); } + + + } + +} + +void looping(char qS[][100], char qC[][100], char aS[]){ + +int k = 0; + while(k < 1){ + printf("\t\t--------------------Round 1-------------------\n\n"); + printf(">>In this round you need to answer 3 questions correctly to move to Round 2<<\n\n"); + + printOutOption(qS,qC,aS);//2 + if (score < 1) { printf("You lost! Better luck next time\n"); break; } else { printf("\t\t--------------------Round 2-------------------\n\n"); printf(">>In this round you need to answer 2 questions correctly to move to Round 3<<\n\n"); - char response; - for (int i = 0; i < 1; i++){ - printf("%s\n", qS[i]); - printf("%s\n", qC[i]); - printf("Enter your answer (A, B, C, or D) or use a lifeline (F for 50/50, H for hint): "); - scanf(" %c", &response); - response = toupper(response); - if (response == 'F') { - fifty_fifty(i); - printf("Enter your answer (A, B, C, or D): "); - scanf(" %c", &response); - response = toupper(response); - }else if (response == 'H') { - hint(i); - printf("Enter your answer (A, B, C, or D): "); - scanf(" %c", &response); - response = toupper(response); - - } - - if(response == aS[i]){ - score++; - correct(score); - - } else { - wrong(score); - } - } + + printOutOption(qS,qC,aS);//3 } + if (score < 1) { printf("You lost! Better luck next time\n"); break; } else { printf("\t\t--------------------Round 3-------------------\n\n"); printf(">>In this round you need to answer 2 questions correctly to move to Round 4<<\n\n"); - char response; - for (int i = 0; i < 1; i++) { - printf("%s\n", qS[i]); - printf("%s\n", qC[i]); - printf("Enter your answer (A, B, C, or D) or use a lifeline (F for 50/50, H for hint): "); - scanf(" %c", &response); - response = toupper(response); - if (response == 'F') { - fifty_fifty(i); - printf("Enter your answer (A, B, C, or D): "); - scanf(" %c", &response); - response = toupper(response); - } else if (response == 'H') { - hint(i); - printf("Enter your answer (A, B, C, or D): "); - scanf(" %c", &response); - response = toupper(response); - - } - } - - - if (response == aS[i]) { - score++; - correct(score); - - } else { - wrong(score); - } + + printOutOption(qS,qC,aS);//3 + } k++; - } } - } void ask_questions(void) { diff --git a/src/main/quizproject.h b/src/main/quizproject.h index d23d32b..79d9a28 100644 --- a/src/main/quizproject.h +++ b/src/main/quizproject.h @@ -12,5 +12,6 @@ void hint(int); void correct(int); void wrong(int); int score = 0; +void printOutOption(char [][100], char [][100],char []); #endif