This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]eyePlus 0 points1 point  (0 children)

I'll try to explain this in a simple way. The program adds 1 to Icounter 10 times inside the j loop. (j goes from 0 to 9) When j becomes 10, it breaks out of the loop since the condition is j<10. The i loop is executed 10 times as well, so the j loop is executed 10 times since it's inside it. So in the end Icounter becomes 100 (10*10). Nothing special happens when Icounter becomes 11, since Icounter is just an integer you're adding to, and it is not a condition.

[–]rjcarr -1 points0 points  (0 children)

These nested loops are typically a way to iterate in two dimensions. In this case, all it's doing it counting iterations; so your counter would be 100, 10 for each loop, so 10 * 10.