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

continuation of the output: This sample program shows how to generate random num

ID: 3757071 • Letter: C

Question

continuation of the output:

This sample program shows how to generate random numbers:

#include <

stdio.h>

#include <stdlib.h>

#include <time.h>

int main() {

int num;

int i;

srand(time(NULL));

for (i=1; i<=10; i++) {

num = rand();

printf("%d

n", num);

}

}

USE C

Write a program named problem.c to generate addition and subtraction math problems TOr a 4th grader. Your program wilL Iirst ask user how many problems they want to do. Then your program will generate problems using two random generated two digits (0-99). The odd number of problems (1,3,5, will be addition problems, and the even number of problems (2,4,6, will be subtraction problems. For subtraction problem, swap two numbers if the first number is smaller than the secona number. You wiII then display the question number, then display the problem, then ask user to answer. If the user answers correctly the first time, the user gets 10 points for the problem. If the user does not answer correctly, you print the problem again, and ask the user to try again. If the user answers correctly second time, the user gets 5 points for this problem. You then display the total points that user gets. Repeat until you give user the number of problems that the user asks for. After the user answers all the problems, calculate the percentage. Display the percentage. If the percentage is above or equal 938, display "Excellent". If the percentage is above or equal 878, display "Very good". Otherwise, print "Keep working hard." The Output Format should look this $./problem Welcome to the Math Genius Program! How many problems would you like to do today?4 0k! You will be given 4 math problems. Good luck with them! Press enter to start. Question 1 92 11103 Correct! 10 points. Total points: 10 Question 2 951085 Correct! 10 points. Total points 20 Question 3 31 5687 Correct! 10 points. Total points 30

Explanation / Answer

If you have any doubts, please give me comment...

#include <stdio.h>

#include <stdlib.h>

#include <time.h>

int main()

{

int n;

srand(time(NULL));

printf(" Welcome to the Math Genius Program! ");

printf(" How many problems would you like to do today?");

scanf("%d", &n);

printf("Ok! You will be given 4 math problems. Good luck with them! ");

printf("Press enter to start.");

// scanf(" ");

getchar();

int n1, n2, res, ans, points = 0, attempts;

for (int i = 0; i < n; i++)

{

attempts = 1;

printf(" Question %d ", (i + 1));

n1 = rand() % 100;

n2 = rand() % 100;

while (attempts != 3)

{

if (i % 2 == 0)

{

res = n1 + n2;

printf("%d + %d = ", n1, n2);

}

else

{

res = n1 - n2;

printf("%d - %d = ", n1, n2);

}

scanf("%d", &ans);

if (res == ans)

{

points += attempts == 1 ? 10 : 5;

printf("Correct! %d points. Total points: %d ", (attempts == 1 ? 10 : 5), points);

break;

}

else

{

attempts++;

printf("Wrong. Please try again. ");

}

}

}

double perc = (points / (n * 10.0))*100;

printf(" You got %.2f%%! ", perc);

if (perc >= 93)

printf("Excellent");

else if (perc >= 87)

printf("Very good");

else

printf("Keep working hard.");

printf(" Thank you for using my math problem generator! ");

return 0;

}