Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

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

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
a) ruby
length is 4
b) ruby
length is 5
c) abc
length is 4
d) syntax error

Answer: a
Explanation: Input string length is taken into consideration and then the case statement is executed.
Output:
ruby
length is 4

Join The Discussion