Learn Create Your Own Split Screen

Next Page

Another statement that can help make loop code more elegant is continue.

Its purpose is to send the flow of execution back up to the top of the loop.

Here's an example:

while (aliens > 0) { display_background(); move_defender(); if (lives_left == 0) continue; display_lives_remaining(); move_defender(); }
The effect is that once lives_left goes down to zero, the while-loop keeps running, but the statements between the continue and the end of the loop won't be executed.