getchar and the input

hello,i want to know that why do we use getchar() before while loop and and when to use it?? like this solution.I dont know when to use getchar().can anyone help??

getchar() just accepts a character.

for better understanding read these

Getchar() is used to get ‘\n’ from stdin left after integer input. It is used when there is a string input next to an integer input.

You may read this thread for further explanation.

Hope You understood… :slight_smile:

that was very much useful…thanks a lot and yes understood :smiley:

welcome… :slight_smile: