I am trying to make a quiz to help my son master his times tables. Is it possible to add a function that computes how quickly he completed the questions (in seconds, or minutes).
Also would like to ask: Why does the program work for any sums that don't have zero as first number? For example (3*5=15 or 5*0=0 but when the question is 0*5 it's given incorrect for entering 0).
Thanks for your help. This is the main part of the code.
#include <stdio.h>
#include <time.h>
#include <conio.h>
int main(void){
int response=0;
int correctAnswers=0;
int incorrectAnswers=0;
int i;//counter
int percentage;
int product;
time_t t;
printf ("Enter number of sums you want to attempt:\n");
scanf ("%d",&response);
if (response==0){
printf ("Thanks for playing\n");
return 0;
}
srand((unsigned) time(&t));
for (i=0;i<=response;i++){
int answer=0;
int a=rand()%12;
int b=rand()%12;
product=a*b;
printf ("%d * %d=\n",a,b);
scanf("%d",&answer);
if ((product=answer)){
printf("That's correct\n");
correctAnswers++;
}
else {
printf ("That's wrong!\n");
incorrectAnswers++;
}