Q:

Write a Ruby program to find the greatest of three numbers

0

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

All Answers

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

Ruby Code:

x,y,z = 2,5,4
if x >= y and x >= z
     puts "x = #{x} is greatest."
elsif y >= z and y >= x 
     puts "y = #{y} is greatest."
else 
     puts "z = #{z} is greatest."
end

Output:

y = 5 is greatest.

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

total answers (1)

Similar questions


need a help?


find thousands of online teachers now