How to validate user input in C?

This program checks if user input is a positive integer or not. If not it simply keeps asking for input again until the user doesn’t enter the positive integer value.

We need to check for the scanf function return value. The scanf returns 1 if the input is integer and 0 if its character.