
Nested loop
In the previous example (Figure 56), we drew 10 circles next to each other by using the For-loop. Our task now is to repeat this loop 9 times (draws a circle field - 10 x 10). We take the advantage of a nested loop, which is a loop within the loop. We put what we want to repeat as a "package" into the next loop. Of course, this new loop must have also a new control variable, we will call it J (Figure 62).

Figure 62: Nested loop
The program works as follows: first draws a line of 10 circles next to each other, then this drawing is repeated 9 times, but each time you draw a line of circles, Y coordinate increases so that the next row is below the previous one. After running the program, we will see following (Figure 63):

Figure 63: Nested loop - a circle field - 10 x 10