Continue Statement

The Continue statement gives you the option to skip over the part of a loop where an external condition is triggered, but to go on to complete the rest of the loop iterations. That is, the current iteration of the loop will be disrupted, but the program will return to the top of the loop. The Continue statement will be within the block of code under the Loop statement, usually after a conditional if statement.

The continue statement (in most computer programming languages), takes the generic form of:

WHILE Boolean expression
statement_1
IF Boolean expression THEN
CONTINUE
ENDIF
statement_2
counter = counter + 1
ENDWHILE
FOR counter in range(n)
statement_1
IF Boolean expression THEN
CONTINUE
ENDIF
statement_2
ENDFOR

In this example program, the user is asked to enter a positive integer and the program will count how many times it goes through the loop until it reaches that number, except it will always skip 5!

Top-Down Design for the Continue Statement

Top-Down Design for Continue Statement

Flowchart for the Continue Statement

Continue Statement flowchart

Pseudocode for the Continue Statement

GET positive_integer
WHILE (counter < positive_integer)
counter = counter - 1
IF (counter + 1 == 5) THEN
CONTINUE
ENDIF
SHOW counter + 1
ENDFOR

Code for the Continue Statement

Example Output

Code example output