Control Structures In Ruby - Study Mode
[#61] What is the output of the given code? counter = 1
while counter < 11
puts counter
counter = counter + 1
end
Correct Answer
(A) Prints the number from 1 to 10
[#62] What is the output of the given code? counter = true
while counter !=false
puts counter
end
Correct Answer
(D) Infinite loop
[#63] What is the output of the given code? i = 0
while i < 5
puts i
i=(i+1)**2
end
Correct Answer
(B) 0 1 4
[#64] What is the output of the given code? a=5
b=15
while a&&b
puts a+b
end
Correct Answer
(C) Infinite loop
[#65] 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
Correct Answer
(C) Infinite loop