I need help with a simple C program I am doing.
I want the program to do something then ask the user if it wants to do it again.
I used a do-while loop for this but as it comes out it's either a bug or there's something I really need to know.
Here is my code btw:
CODE
#include <stdio.h>
main()
{
char a='y';
int b;
do
{
printf("\nEnter a number: ");
scanf("%d",&b);
printf("You entered %d\n\n",b);
printf("try again? (y/n): ");
scanf("%c",&a);
printf("\n");
} while (a!='n');
}
I have a problem with my code and it this is what happens:
Enter a number: 5
You entered 5
try again?(y/n):
Enter a number: _ <---------- cursor
It does not ask if the user tries again. Instead, it goes directly to asking the user too input a new number.
Has anyone encountered this problem before?
I really need help.
Thanks


