What is the output of the given code? length=gets.chomp case length.reverse.length when length=4 print "length is 4" when ...
View Question
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 ...
View QuestionThe expression specified by the when clause is evaluated as the left operand. If no when clauses match, case executes the code of the else clause.
a) True b) False Answer: a Explanation: Else clause is executed only when no ...
View Question
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 ...
View Question
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
What is the output of the given code? age = 4 case age puts "baby" when 0 ...
View Question
The following syntax is used for the ruby case statement.
case expression
when expression , expression … then
code …
else
code
end
The following syntax is used for the ruby case statement. case expression when expression , expression ... then
View Question
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
What is the output of the given code? x=8 y=10 unless x<y puts "x is less than y"
View Question
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
What is the output of the given code? x="ruby".length y="language".length puts x,y unless x>y print "length of ...
View Question
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
What is the output of the given code? x=8 y=10 unless x>y puts "x is less than y"
View Question
What is the output of the given code?
print “2 is less than 3” unless 2>3
What is the output of the given code? print "2 is less than 3" unless 2>3 a) 2>3 b) 2 ...
View Question