diff --git a/src/main/quizproject.c b/src/main/quizproject.c index 6149fa9..bcc5c57 100644 --- a/src/main/quizproject.c +++ b/src/main/quizproject.c @@ -30,13 +30,17 @@ int* randomNumber() { //------------Math_quiz_begin------------ -void math_help(){ - printf( "\n\n Instructions that are supposed to be followed\n" ); - printf("......................................................\n\n" ); - printf( "As soon as you answer a question, you will be directed to the next question without any pause. " ); - printf( "\n\n !! Wish you all the best !! \n\n " ); - printf("......................................................\n" ); - printf( "\n Do you still wish to continue playing ? If yes, then press 1. Else, press 0 : " ); +void math_instruction(){ + printf("\t\n\n------------------------Instructions-------------------------\n\n"); + printf("\tThere are two Math Quiz Game. The first is Easy-Math and the second is Hard-Math\n"); + printf("\tFor Easy-Math, you can choose a number between 1 and 5 to randomly generate a question.\n"); + printf("\tA wrong answer means, you lose and you are out of the quiz Game.\n"); + printf("\tIf you choose any other character or number apart from numbers between 1 and 5, you are out of the Game\n"); + printf("\tIn the Hard-Math quiz, You are presented 10 questions\n\n"); + printf("\t\n\n-------------------------------------------------\n\n"); + printf( "\t\n\n !! Wish you all the best !! \n\n " ); + printf("\t......................................................\n" ); + printf( "\t\n Do you still wish to continue playing ? If yes, then press 1. Else, press 0 : " ); int input1; scanf("%d", &input1); @@ -254,7 +258,7 @@ void e_math_ques() { }; - char e_math_solution[11] = { + char e_math_solution[10] = { 'A', 'D', 'B', @@ -279,25 +283,36 @@ void e_math_ques() { "Solution: The equation of the circle is (x - 3)^2 + (y - 4)^2 = 25.", "Solution: x = 6.", }; - e_math_print(e_math, e_math_possible, e_math_solution, e_math_statement); + + int* randArr = randomNumber(); + int arr[10]; + int p = 0; + for(int i = 0; i < 100; i++){ + if(randArr[i] < 10){ + arr[p] = randArr[i]; + p++; + } + } + e_math_print(e_math, e_math_possible, e_math_solution, e_math_statement, arr); } -void e_math_print(char e_ques[][140], char e_poss[][140], char e_math_solution[], char e_math_statement[][100]){ +void e_math_print(char e_ques[][140], char e_poss[][140], char e_math_solution[], char e_math_statement[][100], int arr[]){ int i = 0; while(i < 10){ - printf("[%d]. %s\n", i+1, e_ques[i]); - printf(" %s\n",e_poss[i]); + int arr1 = arr[i]; + printf("[%d]. %s\n", i+1, e_ques[arr1]); + printf(" %s\n",e_poss[arr1]); printf(" Answer: "); char user_answer; scanf(" %c", &user_answer); user_answer = toupper(user_answer); - if (user_answer == e_math_solution[i]) { + if (user_answer == e_math_solution[arr1]) { printf("Correct!\n"); } else { printf("Wrong!\n"); - printf("%s\n\n", e_math_statement[i]); + printf("%s\n\n", e_math_statement[arr1]); } i++; } @@ -321,7 +336,7 @@ void math_enter_game() { math_choose_game(); break; case 2: - math_help(); + math_instruction(); break; default: printf("\t\t-------------------------------------------------------\n"); diff --git a/src/main/quizproject.h b/src/main/quizproject.h index e469527..86351e0 100644 --- a/src/main/quizproject.h +++ b/src/main/quizproject.h @@ -43,8 +43,8 @@ int math_answer(int); void math_display_choice(); void math_enter_game(); void e_math_ques(void); -void e_math_print(char [][140], char [][140], char [], char [][100]); -void math_help(void); +void e_math_print(char [][140], char [][140], char [], char [][100], int []); +void math_instruction(void); void math_choose_game(void); //------Math_quiz_header_end-------