Question
I have never worked on math quizzes and I'm stuck in the issue below. Write a program that gives simple math quizzes. The main program
I have never worked on math quizzes and I'm stuck in the issue below.
Write a program that gives simple math quizzes.
The main program asks the user if they want to solve a math problem and loops as long as they do. In the loop, the program calls a function named problem(), which returns a value of 0 or 1.The main function adds the return value to a running total of correct answers, and it also keeps a total of how many times it has looped.When the loop is finished the program prints the number of correct answers and the number of questions asked.
The function generates two random numbers that are to be added and displays the two numbers as an arithmetic problem, like this:
247
+ 129
Beneath the display, the function asks the user to enter the answer.The function then calculates the correct answer.If they user's answer equals the correct answer the function displays "Correct" and the return value is 1; otherwise the return value is 0. The function has ONLY ONE return statement.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started