for (x = 0; x < 20; x++)

{

for (y = 0; y < 30; y++)

{

if (y > 10)

break;

cout << '*' << endl;

}

}

Since 10 is not greater than 10, I multiplied 12 by 20 and got 240 stars as my answer. But, the answer is 220(11 times 20) stars. How come the inner loop interates 11 times and not 12 like I thought?

This is a guess, if you changed **if (y > 11)** then you'll have 12. Cause you gotta count zero, 0-11 is 12 and 0-10 is 11.

Topic archived. No new replies allowed.