71.
What is the output of the given code?
var =  1
print "1 -- Value is set\n" if var
print "2 -- Value is set\n" unless var
var = false
print "3 -- Value is set\n" unless var

77.
What is the output of the given code?
x=8
y=10
unless x>y
puts "x is less than y"
end
unless x>y+1
puts "x is less than y+1"
end

78.
What is the output of the given code?
x="ruby".length
y="language".length
puts x,y
unless x>y 
print "length of x is less than that of y"
end

79.
What is the output of the given code?
x=8
y=10
unless x<y
puts "x is less than y"
end
unless x>y+1
puts "x is less than y+1"
end

80.
What is the output of the given code?
age =  5
case age
when 0 .. 2
    puts "baby"
when 3 .. 6
    puts "little child"
when 7 .. 12
    puts "child"
when 13 .. 18
    puts "youth"
else
    puts "adult"
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.