I'm writing a program to create 2 random numbers and ask the user what's the product of these 2 eg (5*4=?). I have written the code for this but the program needs to test the user 10 times. And on top of that I need to say the percentage of all the answers they have answered correctly to display at the end. eg you have answered correctly 60%.
Please help. Im new to C. As you can see I've tried putting in the integers but wherever I put loop++; and while(loop<10) it never comes out right
Code:#include <stdio.h>#include <stdlib.h>
#include <time.h>
#include <conio.h>
void print_rand_msg(const int msg_type);
int main(void)
{
int n1;
int n2;
int prd, guess;
int loop;
loop=0;
srand((unsigned int)time(NULL));
n1 = rand()%12+1;
n2 = rand()%12+1;
prd = n1 * n2;
printf("What is %d x %d\?\n",n1,n2);
if(scanf("%d", &guess) != 1)
printf("Incorrect input.");
else if(guess == prd)
{
printf("CORRECT");
}
else
{
printf("INCORRECT");
}
getch();
return 0;
}