πŸ“Š Ruby
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
πŸ’¬ Discuss
βœ… Correct Answer: (A) 1 2 3 4

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

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.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
220
Total Visits
πŸ“½οΈ
3 y ago
Published
πŸŽ–οΈ
Vinay Kumar
Publisher
πŸ“ˆ
93%
Success Rate