# C++ Program to read the height of a person and the print person is taller, dwarf, or average height person

A person’s height determines whether he/ she is tall, dwarf, or average height person. In different regions of the world, the height ranges are different. We are considering Indian standards. In this article, we shall cover how to write a simple program to determine whether a person is taller, dwarf, or of average height person in C++.

Let us define the height range and corresponding classification first, then we can use them in the algorithm as well as in our implementation.

 Height (cm) Type 150 – 170 Average 170 – 195 Tall Below 150 Dwarf Anything else Abnormal height

Now let us see the algorithm and implementation for the same.

## Algorithm

• Read the height h .
• If h is within 150 and 170, then.
• The person is of average height.
• Otherwise when h is within 170 and 195, then.
• The person is tall.
• Otherwise when h is below 150, then.
• Person is dwarf.
• For some other cases,
• The person has the abnormal height
• End if.

## Example

#include <iostream>
using namespace std;

void solve( int h ) {
if (h >= 150 && h <= 170 ) {
cout << "The person is of average height" << endl;
}
else if (h >= 170 && h <= 195 ) {
cout << "The person is tall" << endl;
}
else if (h < 150 ) {
cout << "The person is dwarf" << endl;
}
else {
cout << "The person has abnormal height" << endl;
}
}

int main()
{
cout << "Height of person A: 172" << endl;
solve( 172 );
cout << "Height of person B: 130" << endl;
solve( 130 );
cout << "Height of person C: 198" << endl;
solve( 198 );
cout << "Height of person D: 160" << endl;
solve( 160 );
}


## Output

Height of person A: 172
The person is tall
Height of person B: 130
The person is dwarf
Height of person C: 198
The person has abnormal height
Height of person D: 160
The person is of average height


## Conclusion

Classification using height is a simple problem where we just use the decision-making with certain conditions. In our implementation there are four classes have been shown, these are tall, dwarf, average, and abnormal height. The height ranges are also defined in the above table. From a simple condition checking if-else solution, the program can classify the person based on his/her given height value.