A

Admin • 802.91K Points
Coach

Q. What will be the output of the given code?

Code:
for num in 1...5
puts num
end
  • (A) 1 2 3 4
  • (B) 1 2 3 4 5
  • (C) 0 1 2 3 4
  • (D) 0 1 2 3 4 5
  • Correct Answer - Option(A)
  • Views: 4
  • Filed under category Ruby
  • Hashtags:

Explanation by: Admin
As the range i.e 1...5 is exclusive the loop will loop till 4 and then it will come out of the loop.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.