but then it wont show wether it is correct answer or not
Code:
do
{
no1 = rand() % 50 + 1;
no2 = rand() % 50 + 1;
pcAns = no1 + no2;
printf("%d + %d = ", no1, no2);
scanf("%d", &userAns);
int scanStatus = scanf("%d", &userAns);
if (scanStatus == 1)
{
if (userAns == pcAns)
{
printf("Congratulation, your have entered the correct answer!!\n");
mark = mark + 10;
}
else
{
printf("Sorry the correct answer is %d \n", pcAns);
}
}
else if(scanStatus == 0)
{
int ch;
while ((ch = getchar()) != '\n' && ch != EOF);
printf("Please answer in digit form\n");
}
count++;
} while (count <= 10);
here is the output
Please enter 1, 2, 3 or 4
1
You have selected ADDITION
Please select a level of difficulty: 1-Beginner, 2-Intermediate, or 3-Advance
1
ADDITION BEGINNER SELECTED
Please answer the 10 quetions given
1 + 34 = a
Please answer in digit form
38 + 13 = a
Please answer in digit form
30 + 41 = a
Please answer in digit form
41 + 13 = 54