V

Vinay Kumar • 8.55K Points
Tutor III

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: 101
  • Filed under category Ruby

Explanation by: Vinay Kumar
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.


Question analytics