Hi,
There is a bug in this addition drill program that I can't fix up. I can't input Y/N characters in this program. Is there anyone who can help me to fix it up?
Code:
#include <conio.h>
#include <stdio.h>
main()
{
int answer, count;
int ch;
ch = getche();
for(count=1; count<11; count++) {
printf("What is %d + %d? ", count, count);
scanf("%d", &answer);
if(answer == count + count) printf("Right!\n");
else{
printf("Sorry, you're wrong\n");
printf("Would you like to try again? Y/N: \n");
scanf("%c", &ch);
if(ch=='Y') {
printf("\nWhat is %d + %d? ", count, count);
scanf("%d", &answer);
if(answer == count+count) printf("Right!\n");
else
printf("Wrong, the answer is %d\n", count+count);
}
else
printf("The answer is %d\n", count+count);
}
}
return 0;
}
Thanks in advance