Continue statement in C language is a loop control statement. This statement forces the next iteration of the loop to take place by skipping any code after this statement. Once the continue statement is executed inside the loop body the control is then transferred to the begining of the loop causing the next iteration to occur.

continue-statement-in-c

Syntax for continue statement:
continue;

Program of continue statement

//An example of continue statement in C
#include<stdio.h>

int main()
{
    int x = 10;

    for(x = 1; x <= 10; x++)
    {
        if (x == 5)
        {
            continue;
        }
        printf("%d\n", x);
    }
    return 0;
}

output

1
2
3
4
6
7
8
9
10


In the above output we saw that the number 5 is missing, it is because in above program we have used continue statement inside the for loop. First of all we have initialized a variable x with value 1 and our test condition is x <= 10, since the condition is true therefore the control enters inside the loop body. Inside the loop, our first statement is if statement. In our if statement we have provided a condition x == 5, since the condition is false so the conditional code inside if statement does not get executed and after that the printf() function is excuted. This process continues until the value of x becomes 5, once the value of x is 5 then the condition inside the if statement becomes true and the conditional code is executed i.e. continue statement gets executed and this causes the control of the loop to transfer to the begining causing the next iteration but the printf() function is not executed now. Now this time the value of x becomes 6 which means our if condition becomes false and the printf() function will get executed and this process is continued till the value of x is 10 but once its value becomes 11 the test condition of for loop becomes false and the loop gets exit.