What is the output of the given code? [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[/code]

Đạt Michio

New member
What is the output of the given code?
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
A. x is less than y
B. x is less than y+1
C. x is less than y
x is less than y+1
D. None of the mentioned
 
Answer: c
Explanation: x is always less than y and y+1 hence both the condition will evaluate to false and corresponding code is executed.
Code:
Output:
x is less than y
x is less than y+1
 

Tìm kiếm

Back
Top