To gets user input for height in C Programming Language. This example shows how you'll gets user input for height and if bad input is entered by the user the c program will loop until gets good input.
If the user entered less than zero the program loop again and user have to enter good input.
If the user entered less than zero the program loop again and user have to enter good input.
- {
- // Gets User input for height
- printf("Height:");
- int height = GetInt();
- // If bad input loop until gets good input
- while ((height < 0) || (height > 23))
- {
- printf("Invalid Entry, Try Again:");
- height = GetInt();
- }
- }