Question.Use rand to produce two positive one-digit integers.It should then type a question such as:
How much is 6 times 7?
The student then types the awnser .Your program checks the students awnser.If it is correct, printf "Very good!" and then ask another multiplication question.If the awnser is wrong printf"No.Please try again" and then let the student try the same question repeatedly until he gets it right.Note.Also use user defined functions.
Code:
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int riwo ( int ,int, int ); //function prototype
int main()
{
int num1, num2, awn;
srand(time(NULL));
num1 = 1+ rand () % 10;
num2 = 1+ rand() % 10;
printf ("What is %d times %d: ", num1 , num2);
scanf ("%d", &awn );
if ( riwo(num1, num2,awn) == 1 )
printf ("Very good\n");
else if ( riwo(num1, num2, awn) == 0)
printf ("You are wrong\n");
system("PAUSE");
return 0;
}
int riwo (int a, int b, int tot )
{
if ( tot == a*b )
return (1);
else
return (0);
}
I cant do the part where it says if it is wrong print the same thing again..help me out...