×

Ruby Tutorial

Ruby Basics

Ruby Control Statements

Ruby Methods

Ruby Classes and Methods

Ruby Arrays

Ruby Sets

Ruby Strings

Ruby Classes & Objects

Ruby Hash

Ruby Tools

Ruby Functions

Ruby Built-in Functions

Misc.

Ruby Programs

Ruby program to read the height of a person and the print person is taller, dwarf, or average height person

Last Updated : December 15, 2025

Problem Solution

In this program, we will read the height of a person from the user. Then we will print person taller, dwarf, or average height person.

Program/Source Code

The source code to read the height of a person and the print person is taller, dwarf or average height person is given below. The given program is compiled and executed successfully.

# Ruby program to read the height of a person 
# and the print person is taller, dwarf, 
# or average height person

print "Enter height: ";
height = gets.chomp.to_f;  

if height >= 150.0 && height <= 170.0 
    print "Person is average height person";
elsif height > 170.0 && height <= 195.0
    print "Person is taller";
elsif height < 150.0 
    print "Person is dwarf";
else
    print "Abnormal height";
end

Output

Enter height: 186.2
Person is taller

Explanation

In the above program, we read the height of a person from the user. Then we check the height of the person and printed the appropriate message based on input height that person is taller, dwarf, or average height person.

Ruby Basic Programs »


Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.