Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C

continue — skip the rest of an iteration

The continue; statement skips the rest of the current iteration of the innermost loop without terminating that loop.

Version: C23; repository compiler flag, production runtime not attested

Syntax

continue;

continue; is a jump statement permitted only within a loop body. It skips the remainder of the innermost loop's current iteration.

In for, the update expression executes next, followed by the condition test. In while and do ... while, the condition is tested next; another iteration is not guaranteed.

Unlike break, continue does not terminate the loop. Inside a loop's switch, it targets the loop; a switch alone does not make it valid.

Warning: skipping a counter update in while can cause an infinite loop. The example skips even numbers; ++i still executes.

Examples

#include <stdio.h>

int main(void)
{
    for (int i = 1; i <= 5; ++i) {
        if (i % 2 == 0) {
            continue;
        }
        printf("%d\n", i);
    }
    return 0;
}

Result

1
3
5

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources