ok, so its the <enter> that makes the problem. Thanks boss. I got it figured out now.

The <Enter> is basically a newline character. So this newline character is still in the input stream. To get rid of it I just need to call a getchar() function. It automatically reads this '\n' and moves on to the next line. So the simple solution is to call a getchar() function after every scanf functions.

Thanks xpi0t0s.