๐Ÿ“œ
B.TECH III YEAR โ€ข II SEMESTER โ€ข R22

Scripting Languages - Lab Manual

Scripting Languages Laboratory โ€ข Program 5 Solution

๐Ÿ“˜ R22 Regulation ๐ŸŽ“ III Year ๐Ÿ“š II Semester ๐Ÿ“œ Scripting Languages ๐Ÿ’Ž Ruby โ€ข TCL โ€ข Perl ๐Ÿงช Lab Program
Aim of Program 5

Write a Ruby script to find the greatest of three numbers.

โ† All Programs
Solution

Aim:

☛   Write a Ruby program to find the greatest of three numbers.

Solution :

PROGRAM: (greatest_num.rb)

 
puts "Enter three numbers:"
a = gets.to_i
b = gets.to_i
c = gets.to_i

if a >= b && a >= c
  puts "#{a} is the greatest."
elsif b >= a && b >= c
  puts "#{b} is the greatest."
else
  puts "#{c} is the greatest."
end


OUTPUT:

 
Enter three numbers:
45
25
21
45 is the greatest.



โ† Back to Scripting Languages Lab Programs ๐Ÿ“š All Lab Manuals