C Program to Accept the Height of a Person & Categorize as Taller, Dwarf & Average

This C program accepts the height of a person & categorize as taller, dwarf & average.

Problem Description

This program accepts the height of a person as input and categorizes as taller, dwarf & average.

Problem Solution

1. Take the height of a person as input.
2. Using if,else statements, categorize it as taller, dwarf & average and print the output accordingly.
3. Exit.

Program/Source Code

Here is source code of the C program to accept the height of a person & categorize as taller, dwarf & average. The C program is successfully compiled and run on a Linux system. The program output is also shown below.

  1. /*
  2.  * C program to accept the height of a person in centimeter and
  3.  * categorize the person based on height as taller, dwarf and
  4.  * average height person
  5.  */
  6.  
  7. #include <stdio.h>
  8. void main()
  9. {
  10.     float height;
  11.  
  12.     printf("Enter  the Height (in centimetres) \n");
  13.     scanf("%f", &height);
  14.     if (height < 150.0)
  15.         printf("Dwarf \n");
  16.     else if ((height >= 150.0) && (height <= 165.0))
  17.         printf(" Average Height \n");
  18.     else if ((height > 165.0) && (height <= 195.0))
  19.         printf("Taller \n");
  20.     else
  21.         printf("Abnormal height \n");
  22. }
Program Explanation

1. Take the height of a person as input and store it in the variable height.
2. If the variable height is lesser than 150 cm, then print the output as “Dwarf”.
3. If the variable height is lesser than or equal to 165 cm and greater than or equal to 150 cm, then print the output as “Average Height”.
4. If the variable height is lesser than or equal to 195 cm and greater than 165 cm, then print the output as “Taller”.
5. Exit.

advertisement
advertisement
Runtime Test Cases
Enter  the Height (in centimetres)
165
Average Height
 
Enter  the Height (in centimetres)
140
Dwarf
 
Enter  the Height (in centimetres)
190
Taller

Sanfoundry Global Education & Learning Series – 1000 C Programs.

Here’s the list of Best Books in C Programming, Data-Structures and Algorithms

If you wish to look at other example programs on Simple C Programs, go to Simple C Programs. If you wish to look at programming examples on all topics of C, go to C Programming Examples.

If you find any mistake above, kindly email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.