Answer:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
srand(time(NULL));
int num1, num2;
int val;
while (true)
{
num1 = rand() % 100 + 1; //Random number between 1-100
num2 = rand() % 100 + 1; //Random number between 1-100
if (num1 >= num2)
{
printf("%d - %d = ", num1, num2);
scanf("%d",&val);
if (val == num1-num2)
{
printf("Correct!\\");
}
else
{
printf("Incorrect!\\");
}
}
else
{
printf("%d - %d = ", num2, num1);
scanf("%d",&val);
if (val == num2-num1)
{
printf("Correct!\\");
}
else
{
printf("Incorrect!\\");
}
}
}
}
Step-by-step explanation:
First, we create two random numbers and save the values. Then we check to see which value is larger. Based on that, we change how we display the format to the user. Then we check to see if the user input number is equivalent to the subtraction problem. If it is, we display Correct! Else, we display Incorrect!
Cheers.