Continue Statement in C

Similar, to break statement continue statement is also used to manipulate program flow in a loop structure. When a continue statement is encountered inside a loop, control jumps to the beginning of the loop for next iteration, skipping the execution of statements inside the body of the loop for the current iteration.

Simply understand that the continue keyword executing the code after the loop.

Syntax of continue statement:

1

continue;

The simple code above is the syntax for continue statement.

Flowchart of continue statement

Example of continue Statement

Let’s see the simple example of continue statement:

1

2

3

4

5

6

7

8

9

10

11

12

#include <stdio.h>

intmain()

{

intx;

for(x=10;x>5;x--)

{

if(x==7)

continue;

printf("%d\n",x);

}//end for loop

return0;

}

When you run above program, the output will be following:

1

2

3

4

10

9

8

6

Notice that number 7 is not present in the output. This occurs because when the condition x == 7 is true, the continue statement is executed, thus skipping the printf() function and continuing program flow with the next iteration of the for a loop.