V

Vinay Kumar • 8.55K Points
Tutor III

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

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


Question analytics