82.
What is the output of the given code?
age =  4
case age
puts "baby" when 0 .. 2
puts "little child" when 3 .. 6
puts "child" when 7 .. 12
puts "youth" when 13 .. 18
puts "adult" else
end

83.
What is the output of the given code?
for counter in 1..5
case counter
when 0 .. 2
    puts counter
    puts "baby"
when 3 .. 6
    puts counter
    puts "little child"
when 7 .. 12
    puts counter
    puts "child"
else
    puts counter
    puts "adult"
end
end

84.
What is the output of the given code?
string = gets.chomp
case string
when string = "a"
print "alphabet a"
when string = "b"
print "alphabet b"
when string = "c"
print "alphabet c"
else 
    print "some other alphabet"
end

86.
What is the output of the given code?
length=gets.chomp
case length.length
when length=4
print "length is 4"
when length=5
print "length is 5"
end

87.
What is the output of the given code?
length=gets.chomp
case length.reverse.length
when length=4
print "length is 4"
when length=5
print "length is 5"
end

Read More Section(Control Structures in Ruby)

Each Section contains maximum 100 MCQs question on Control Structures in Ruby. To get more questions visit other sections.