Question 1 of 25
Hints left: 3
Q1
What is the output of the given code? l=9 case l print "ruby" when l==9 print "language" when l==10 end
Q2
What is the output of the given code? m=0 loop do print "ruby" m+=1 break if m==5 end
Q3
What is the output of the given code? i = 3 while i > 0 do print i i -= 1 end
Q4
What is the output of the given code? i = 3 while i > 0 do puts i i -= 1 end j = 3 until j == 0 do puts j j -= 1 end
Q5
What is the output of the given code? length=gets.chomp case length.reverse.length when length=4 print "length is 4" when length=5 print "length is 5" end
Q6
What is the output of the given code? i = 0 while i < 5 puts i i=(i+1)**2 end
Q7
What is the output of the given code? m= 8 loop do m += 2 puts m break if m == 16 end
Q8
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
Q9
What is the output of the given code? a=5 b=15 while b>a puts a*(b-a) while a>b a+=1 b-=1 end end
Q10
What is the output of the given code? counter = 0 until counter >= 10 puts counter counter+=1 end
Q11
What is the output of the given code? m=0 loop do puts 101 m+=1 break if m==5 end
Q12
What is the output of the given code? i = 50 j=55 while i > 25 && i*j<100 do puts (50*j)/i i -= 1 j-=2 end
Q13
What is the output of the given code? counter = 1 until counter > 10 puts counter counter+=1 end
Q14
What is the output of the given code? m=5 loop do m-=1 break if m==0 end
Q15
What is the output of the given code? m=0 loop do puts m*10 m+=1 break if m==5 end
Q16
What is the output of the given code? a="hungry" until !a puts "hungry" a=!a end
Q17
What is the output of the given code? counter = true while counter !=false puts counter end
Q18
The complement of while loop is until loop.
Q19
What is the output of the given code? a=5 b=15 while a&&b puts a+b end
Q20
A case statement compares the expression specified by case and that specified by when using the === operator and executes the code of the when clause that matches.
Q21
What is the output of the given code? i = 50 j=55 while i > 25 && j>35 do puts 50*j/i i -= 1 j-=2 end
Q22
While loop checks the condition and the loop keeps on running till the condition is true, it stops when the condition becomes false.
Q23
What is the output of the given code? counter = 1 while counter < 11 puts counter counter = counter + 1 end
Q24
What is the output of the given code? i = 50 while i > 25 do print 50/i i -= 1 end
Q25
What is the output of the given code? a = 5 b=10 while a<b do puts a*b a+=2 b-=2 end