Q. What will be the output of the given code?
Code:
counter = 1 while counter < 5 puts counter counter = counter + 1 end
β
Correct Answer: (A)
Prints the number from 1 to 4
Explanation: Counter value is initialized to 1 and it keeps on looping till the counter is less than 5.