This is because when you entered your character for the first call to scanf, in addition to entering the character itself, you also pressed "Enter" (or "Return"). The "Enter" key sends the standard data input '\ n', which is checked by your second call to scanf.
That way, the second scanf just gets everything that is the next character in your input stream and assigns it to your variable (i.e. if you don't use a space in this scanf statement). So, for example, if you are not using space in the second scanf and
You do it:
a<enter> b<enter>
The first scanf assigns "a" and the second scanf assigns "\ n".
But when you do this:
ab<enter>
Guess what will happen? The first scanf will assign "a", and the second scanf will assign "b" (not "\ n").
Another solution is to use scanf("%c\n", &c); for your first scanf statement.
source share