MCQ Practice

All Countries ๐ŸŒ Mcq University Model MCQ Single Answer ENGLISH RUBY WHILE LOOP 2025

Focused practice with instant answer feedback, progress tracking, and community notes in one consistent workspace.

Answer feedback follows the same pattern everywhere on BrainBoost.

Green means correct, red means incorrect, and your selected answer is underlined in purple.

Question Set
Interest
Timer
Question
Q:

What is the output of the given code?

counter = 1
while counter < 11
  puts counter
  counter = counter + 1
end

  • counter = 1: Initializes a variable counter with the value 1.

  • while counter < 11: This is the loop condition. The code inside the loop will execute as long as the value of counter is less than 11.

  • puts counter: This line prints the current value of counter to the console.

  • counter = counter + 1: This line increments the counter by 1 in each iteration.

Now, let's trace the execution:

  1. Iteration 1: counter is 1. 1 < 11 is true. puts 1. counter becomes 2.

  2. Iteration 2: counter is 2. 2 < 11 is true. puts 2. counter becomes 3.

  3. ...

  4. Iteration 10: counter is 10. 10 < 11 is true. puts 10. counter becomes 11.

  5. Iteration 11: counter is 11. 11 < 11 is false. The loop terminates.

Community Help

Added solution videos and notes for this question

Please log in if you'd like to share your video or note showing how to solve this question. Once logged in, you can download notes, subscribe to the YouTube channel, and react to notes and videos.