Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

write a C program that randomly generates, conducts, and scores a simple arithme

ID: 3658266 • Letter: W

Question

write a C program that randomly generates, conducts, and scores a simple arithmetic quiz based on certain user parameters. The arithmetic quiz will ask questions dealing with simple addition, subtraction, multiplication, and division. The user will be asked to enter the number of questions for the quiz, between 1 and 10 (be sure to verify and re-prompt if necessary) and a difficulty level between 1 and 4 (also verify).

Explanation / Answer

#include #include int initialize(void); int additionquiz(void); int subtractionquiz(void); int numbers[10]; int clear(void); int multiplicationquiz(void); int divisionquiz(void); int main() { while(1==1) { int choice; initialize(); printf("Arithmetic Quiz 4/10/2012"); printf(" 1 - Addition Quiz 2 - Subtraction Quiz 3 - Multiplication Quiz 4 - Division Quiz 5 - Exit Program "); scanf("%d",&choice); if(choice==1) { clear(); additionquiz(); } else if(choice==2) { clear(); subtractionquiz(); } else if(choice==3) { clear(); multiplicationquiz(); } else if(choice==4) { clear(); divisionquiz(); } else if(choice==5) { exit(EXIT_SUCCESS); } else { printf(" %cPlease input a valid option ",7); main(); } } return 0; } /* Function for clearing the page */ int clear() { int i; for(i=0;i9) { a=0; diff++; } if(diff>9); { diff=0; } if(b>9); { b=0; } /* Main part of the addition quiz */ while(1==1) { printf(" %d + %d = ",numbers[a],numbers[b]); scanf("%d",&ans); if(ans==numbers[a]+numbers[b]) { printf(" Your answer is CORRECT!!! "); a++; } else { printf(" Your answer is WRONG!!! "); additionquiz(); } /* The loop for addition quiz" */ while(1==1) { printf(" 1 - Answer another addition question 2 - Go back to main menu 3 - Exit program "); scanf("%d",&again); if(again==1) { clear(); break; } else if(again==2) { clear(); main(); } else if(again==3) { exit(EXIT_SUCCESS); } else { printf("%cPlease input a valid option. ",7); continue; } } continue; } } /* Function for the subtraction quiz */ int subtractionquiz() { /* Randomizing the question in subtraction quiz */ int a,b,diff,ans,again; a=0; diff=1; if(a>9) { a=0; diff++; } if(diff>9); { diff=0; } b=a+diff; if(b>9); { b=0; } /* Main part of the subtraction quiz */ while(1==1) { /* Not allowing questions with negative answer */ while(numbers[a]9) { a=0; diff++; } if(diff>9); { diff=0; } if(b>9); { b=0; } /* Main part of the multiplication quiz */ while(1==1) { printf(" %d x %d = ",numbers[a],numbers[b]); scanf("%d",&ans); if(ans==numbers[a]*numbers[b]) { printf(" Your answer is CORRECT!!! "); a++; } else { printf(" Your answer is WRONG!!! "); clear(); multiplicationquiz(); } /* Loop for multiplication quiz */ while(1==1) { printf(" 1 - Answer another multiplication question 2 - Go back to main menu 3 - Exit program "); scanf("%d",&again); if(again==1) { clear(); break; } else if(again==2) { clear(); main(); } else if(again==3) { exit(EXIT_SUCCESS); } else { printf("%cPlease input a valid option. ",7); continue; } } continue; } } /* Function for division quiz */ int divisionquiz() { /* Randomizing the division quiz */ int a,b,diff,ans,again,remain; a=0; diff=1; if(a>9) { a=0; diff++; } if(diff>9); { diff=0; } b=a+diff; if(b>9); { b=0; } /*Main part of the division quiz */ while(1==1) { /* Not allowing division by 0 or answers less than 1 */ if(numbers[b]==0 || (numbers[a]