I am programming a math quiz program for the college assignment below are a part of my code, the question is if user key in a char for the answer the program goes wrong, how to detect if the user keyed in char so i can send a message to user and say "Please enter a digit"
Code:do {
no1 = rand() % 50 + 1;
no2 = rand() % 50 + 1;
pcAns = no1 + no2;
printf("%d + %d = ", no1, no2);
scanf("%d", &userAns);
if (pcAns == userAns)
{
printf("Congratulation, your have entered the correct answer!!\n");
mark = mark + 10;
}
else
printf("Sorry the correct answer is %d \n", pcAns);
count++;
} while (count <= 10);