How to Gets User Input For Height in C Programming

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.


  1. {
  2.     // Gets User input for height
  3.     printf("Height:");
  4.     int height = GetInt();
  5.    
  6.     // If bad input loop until gets good input
  7.     while ((height < 0) || (height > 23))
  8.     {
  9.         printf("Invalid Entry, Try Again:");
  10.         height = GetInt();
  11.     }
  12. }


Learn More :