Multiple choice

Which loop will iterate 10 times?

  1. for (int i=0; i<10; i++)

  2. for (x=0; x<10; x++)

  3. for (int y=1; y<10; y++)

  4. for (int j=0; j<=10; j++)

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The loop in Option A starts with i = 0 and continues as long as i is strictly less than 10, incrementing by 1 each time. This executes the loop body for values 0 through 9, which is exactly 10 iterations. Option C only runs 9 times, and Option D runs 11 times.