there are lots of similar question in forum but no one get me the right answer.
Hi every one
I'm really new in c
programming and I have this problem.
I give you an simple code example of my problem:
#include <stdio.h>
int main ()
{
char ch = 'y';
int a = 0, b = 0, c = 0;
while (ch == 'Y' || ch == 'y')
{
printf ("please enter the numbers: ");
scanf ("%d", &a);
scanf ("%d", &b);
c = a + b;
printf ("sum = %d \n", c);
printf("do you want to calculate another numbers? N/Y\n");
scanf('%c',&ch);
}
return 0;
}
in this code the program doesn't wait for last scanf (scanf('%c',&ch);
)
I try to use getchar();
too, but the program doesn't respond to that too.
can any one give me a solution in this program and every program that I will do in the future?