Q:

C# program to take height as input and print its category as Dwarf, Average, and Tall

0

C# program to take height as input and print its category as Dwarf, Average, and Tall

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program:

The source code to print the height category in C# is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.

//Program to take height as input and print 
//its category as Dwarf, Average, and Tall.

using System;

class program
{
    public static void Main()
    {
        int height=0;
        
        Console.WriteLine("Enter your Height (in centimeters): ");
        height = int.Parse(Console.ReadLine());

        if (height < 160)
            Console.WriteLine("You are Dwarf person");
        else if ((height >= 160) && (height <= 170))
            Console.WriteLine("You are average height person");
        else if (height >= 170)
            Console.WriteLine("You are tall person");
        else
            Console.WriteLine("Entered height is abnormal");
    }
}

Output:

Enter your Height (in centimeters):
172
You are tall person
Press any key to continue . . .

Explanation:

In the above program, we created a program class that contains Main() method, In the Main() method we created a local variable height initialized with 0. Then we took height as an input, and then check conditions and print the appropriate message on the console screen.

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C# Basic Programs | Class, Object, Methods

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C# program to implement phonebook... >>
<< C# program to generate random numbers...