case expression
when expression , expression ... then
code ...
else
code
endSelect an option to see the answer and solution.
Practice every MCQ with options. Use Show answers when you want the correct option and solution.
120
Questions
5/6
Page
Pick an option on a question to see the right answer and solution.
case expression
when expression , expression ... then
code ...
else
code
endSelect an option to see the answer and solution.
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
endSelect an option to see the answer and solution.
for counter in 1..5
case counter
when 0 .. 2
puts counter
puts "baby"
when 3 .. 6
puts counter
puts "little child"
when 7 .. 12
puts counter
puts "child"
else
puts counter
puts "adult"
end
endSelect an option to see the answer and solution.
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"
endSelect an option to see the answer and solution.
Select an option to see the answer and solution.
length=gets.chomp
case length.length
when length=4
print "length is 4"
when length=5
print "length is 5"
endSelect an option to see the answer and solution.
length=gets.chomp
case length.reverse.length
when length=4
print "length is 4"
when length=5
print "length is 5"
endSelect an option to see the answer and solution.
l=9
case l
print "ruby" when l==9
print "language" when l==10
endSelect an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
counter = 1
while counter < 11
puts counter
counter = counter + 1
endSelect an option to see the answer and solution.
counter = true
while counter !=false
puts counter
endSelect an option to see the answer and solution.
i = 0
while i < 5
puts i
i=(i+1)**2
endSelect an option to see the answer and solution.
a=5
b=15
while a&&b
puts a+b
endSelect an option to see the answer and solution.
a=5
b=15
while b>a
puts a*(b-a)
while a>b
a+=1
b-=1
end
endSelect an option to see the answer and solution.
i = 3
while i > 0 do
print i
i -= 1
endSelect an option to see the answer and solution.
i = 50
while i > 25 do
print 50/i
i -= 1
endSelect an option to see the answer and solution.
a = 5
b=10
while a<b do
puts a*b
a+=2
b-=2
endSelect an option to see the answer and solution.
i = 50
j=55
while i > 25 && j>35 do
puts 50*j/i
i -= 1
j-=2
endSelect an option to see the answer and solution.
Q100
Open questioni = 50
j=55
while i > 25 && i*j<100 do
puts (50*j)/i
i -= 1
j-=2
endSelect an option to see the answer and solution.