You have to just give one space before %c in scanf
scanf(" %c",&ch);
This is because after giving the input we pressed enter that enter is stored in buffer and this read again by our program, some time we clear we flush our input/output buffer you can check in Linux fflush()
I think so is the function, there is lots of way but this is the easiest way that I know.
Hope useful for you.