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?
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

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
a) alphabet a
b) b
alphabet b
c) alphabet c
d) Syntax error

Answer: b
Explanation: After taking input from the user will check which string is entered and goes to particular case statement.
Output:
b
alphabet b

Join The Discussion