The issue is in scanf
scanf reads the input after enter/return key is pressed.But the newline generated by it is not consumed by scanf.Hence next time when scanf reads the input it reads newline instead of your input.
I tried using fflush on my Linux system..2.6.9-22.EL..But it doesnt seem to work
Alternative solution could be as under:
U can use scanf as
In this case scanf will read the newline and discard it