Learn Create Your Own Split Screen

Next Page

Sometimes you'll find yourself with one loop inside another loop, called a nested-loop.

It's important for you to know that break only breaks out of one level of loop.

for (row= 0; row < 5; row++) { reset_row(); for (column=0; column < 10; column++) { create_alien(row, column); if (column_full) break; } }
In this example, when the column_full variable becomes true we will exit from the inner for-loop and not create any more columns, but the outer for-loop keeps running and we'll continue to process rows.

Break only breaks out of the loop that it's in.