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

This is a C# Program to accept the height of a person & categorize as tall, dwarf or average.

Problem Description

This C# Program accepts the height of a person & categorizes it as Tall, Dwarf or Average.

Problem Solution

Here the program accepts height of a person in centimeters. Then, it categorizes it based on the height. If height is less than 150 centimeter, then the person is dwarf and if the height is between 151 to 165 then it is categorized as average and if the height is between 165 to 175 then it is categorized as tall.

Program/Source Code

Here is source code of the C# Program to Accept the Height of a Person & Categorize as Tall, Dwarf or Average. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.

```/*
* C# Program to Accept the Height of a Person & Categorize as
* Tall, Dwarf or Average
*/
using System;
class program
{
public static void Main()
{
float height;
Console.WriteLine("Enter  the Height (in centimeters) \n");
if (height < 150.0)
Console.WriteLine("Dwarf \n");
else if ((height >= 150.0) && (height <= 165.0))
Console.WriteLine(" Average Height \n");
else if ((height >= 165.0) && (height <= 195.0))
Console.WriteLine("Taller \n");
else
Console.WriteLine("Abnormal height \n");
}
}```
Program Explanation

In this C# program, we are reading the height of a person using ‘height’ variable. Nested-if else condition statement is used to print the height of a person.

If condition statement is used to check the height of the person is less than 150.00 centimeters. If the condition is true then execute the statement and print the height of the person. Otherwise if the condition is false, then execute else if condition statement. Check the condition that the height of the person is between 150.00 to 165.00 centimeters using logical AND operator.

If it’s true then it will execute the statement, otherwise, another else if condition statement that height of the person should between 165.00 to 195.00 centimeters. If the condition is true, then execute the statement and print the height of the person.

Runtime Test Cases
```
Enter  the Height (in centimeters)
165
Average Height```

Sanfoundry Global Education & Learning Series – 1000 C# Programs.

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!
If you wish to look at all C# Programming examples, go to 1000 C# Programs.

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