Continue Statement in C (original) (raw)

Last Updated : 15 Jun, 2026

The continue statement in C is a jump statement used to skip the remaining statements of the current loop iteration and move directly to the next iteration of the loop. It can be used inside for, while, and do-while loops.

#include <stdio.h>

int main() {

// Loop from 1 to 5
for (int i = 1; i <= 5; i++)
{

    // Skip number 3
    if (i == 3)
        continue;
    printf("%d ", i);
}

return 0;

}

`

**Explanation: The loop runs from 1 to 5 and print each number. We add the continue statement inside an if statement that checks if the number is 3 i.e. **i == 3. If it is, continue is reached and printing of 3 is skipped.

Working of C Continue

working of continue in c

Working of C continue in for Loop

Working of the Continue Statement

The continue statement works as follows:

Flowchart of Continue Statement

The flowchart of the continue can be constructed using the understanding of the continue we got from above.

flowchart of continue in c

Example: Print Odd Numbers from 1 to 10

C `

#include <stdio.h>

int main() { int n = 1;

// Loop from 1 to 10
while (n <= 10)
{

    // If the number is even, skip iteration to avoid printing it
    if (n % 2 == 0)
    {
        n++;
        continue;
    }
    printf("%d ", n);
    n++;
}

return 0;

}

`

**Explanation: The condition checks if the number **n is even and when it's true it skips to the next iteration which prevents the print statement from executing as the print statement is below the continue so when the continue is executed (for even numbers), no printing is done.

Use continue in Nested Loops

The continue statement will only work in a single loop at a time. So, in the case of nested loops, we can use the continue statement to skip the current iteration of the inner loop when using nested loops.

C `

#include <stdio.h>

int main() {

// Outer loop with 3 iterations
for (int i = 1; i <= 3; i++)
{

    // Inner loop to print integer 1 to 4
    for (int j = 0; j <= 4; j++)
    {

        // Continue to skip printing number 3
        if (j == 3)
            continue;
        printf("%d ", j);
    }
    printf("\n");
}
return 0;

}

`

Output

0 1 2 4 0 1 2 4 0 1 2 4

The continue skips the current iteration of the inner loop when it executes in the above program. As a result, the program is controlled by the inner loop update expression. In this way, 3 is never displayed in the output.

Related Article