Academic Program

continue Statement

Continue Statement

The continue statement causes programs to jump back to the beginning of a loop without completing the current iteration.

Syntax

continue;

continueStatement.png
 
1
2
3
4
5
6
7
8
int i = 0;
 
while (i < 5)
{
    i++;
    if (i == 2) continue; //Skip remaining iteration when i=2.
    printf("Loop iteration %d\n", i);
}

The expected output for this loop is:

Loop iteration 1
Loop iteration 3
Loop iteration 4
Loop iteration 5