Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For this project you will create a program that will test the users proficiency at solving different types of math problems. The program will be
For this project you will create a program that will test the users proficiency at solving different types of math problems. The program will be menu driven. The user will select either addition, subtraction, multiplication or division problems. The program will then display a problem, prompt the user for an answer and then check the answer displaying an appropriate message to the user whether their answer was correct or incorrect. The program will also keep statistics on how many problems were answered correctly.
This week you will continue with the project by adding the Subtraction, Multiplication and Division functions. In order to test the menu function completely we needed to write all of the functions. The addition should be working but the remaining functions are empty. These empty functions are called blackboxes.
So now lets add the code for the remaining functions. Pay particular attention to the division function. You will want to do only integer division showing the answer and remainder back to the user. Prompt the user for both the answer and remainder for all division problems. Use the Modulus operator to calculate the correct answer and remainder. Also include logic to make the numerator the larger of the two numbers to avoid answers less than 1.
I dont know how to do this in C and I need to do it in c. Here is my code so far
#include
int main() {
int input, answer, num1, num2, num3, num4, num5; //decalring values
num1 = 1;
num2 = 2;
num3 = 3;
num4 = 4;
num5 = 5;
printf("Math Practice program Main Menu ");
printf(" ");
printf("1. Addition ");
printf("2. Subtraction ");
printf("3. Multiplication ");
printf("4. Division ");
printf("5. Exit ");
printf("Select an option: ");
scanf("%d", &input); //read user input
if (input == num1) {
printf("10 + 10 = ? "); //simple equation to answer
scanf("%d", &input); //read user input
answer = 20; //declare the correct answer to the value of answer
if (answer == input) { //create condition for correct
printf("correct! ");
}
else { //if condition not met print incorrect
printf("incorrect ");
}
return 0;
}
if (input == num2) {
printf("9 - 6 = ? "); //simple equation to answer
scanf("%d", &input); //read user input
answer = 3; //declare the correct answer to the value of answer
if (answer == input) { //create condition for correct
printf("correct! ");
}
else { //if condition not met print incorrect
printf("incorrect ");
}
return 0;
}
if (input == num3) {
printf("12 * 2 = ? "); //simple equation to answer
scanf("%d", &input); //read user input
answer = 24; //declare the correct answer to the value of answer
if (answer == input) { //create condition for correct
printf("correct! ");
}
else { //if condition not met print incorrect
printf("incorrect ");
}
return 0;
}
if (input == num4) {
printf("14 / 7 = ? "); //simple equation to answer
scanf("%d", &input); //read user input
answer = 2; //declare the correct answer to the value of answer
if (answer == input) { //create condition for correct
printf("correct! ");
}
else { //if condition not met print incorrect
printf("incorrect ");
}
return 0;
}
if (input == num5) {
return 0;
}
}
Please help...
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