This C program accepts the height of a person & categorize as taller, dwarf & average.
This program accepts the height of a person as input and categorizes as taller, dwarf & average.
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.
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.
/*
* C program to accept the height of a person in centimeter and
* categorize the person based on height as taller, dwarf and
* average height person
*/
#include <stdio.h>
void main()
{
float height;
printf("Enter the Height (in centimetres) \n");
scanf("%f", &height);
if (height < 150.0)
printf("Dwarf \n");
else if ((height >= 150.0) && (height <= 165.0))
printf(" Average Height \n");
else if ((height > 165.0) && (height <= 195.0))
printf("Taller \n");
else
printf("Abnormal height \n");
}
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.
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
- Practice Computer Science MCQs
- Apply for Computer Science Internship
- Apply for C Internship
- Practice BCA MCQs
- Watch Advanced C Programming Videos