A

Admin • 828.03K Points
Coach

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

Code:
counter = 1
while counter < 5
puts counter
counter = counter + 1
end
  • (A) Prints the number from 1 to 4
  • (B) Prints the number from 1 to 5
  • (C) Prints the number from 2 to 5
  • (D) Prints the number from 2 to 4
  • Correct Answer - Option(A)
  • Views: 8
  • Filed under category Ruby
  • Hashtags:

Explanation by: Admin
Counter value is initialized to 1 and it keeps on looping till the counter is less than 5.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.