August 2000
Intermediate to advanced
800 pages
13h 15m
English
The continue statement is similar to the break statement except that instead of stopping the loop entirely, only the current execution of the loop is stopped. Control is returned to the closing curly brace and the loop continues. Inside for loops, described below, increments will occur just as if control had reached the end of the loop otherwise.
As you might imagine, this function is used to skip parts of a loop when a condition is met. Listing 3.7 demonstrates this idea. Random numbers are generated inside a loop until ten numbers, each greater than the previous, are produced. Most of the time the body of the loop is skipped due to the if statement that triggers a continue statement.
Read now
Unlock full access