Programming: Nested For Loop

For loops can be nested to cycle in a multidimensional way.



Structure: for () { for () { Code } } Example: for (int x = 0; x<3; x++) { for (int y = 0; y<3; y++) { //Print the x and y values } } If the values of x and y were printed, the output may look like this: 0, 0 0, 1 0, 2 1, 0 1, 1 1, 2 2, 0 2, 1 2, 2
Back to blog

Leave a comment

Please note, comments need to be approved before they are published.