Continue statements in C is required When we want to take the control to the beginning of the loop, bypassing the statement inside the loop, a statement not yet executed, the keyword continues to allow us to do this.

The continue statement in C programming works rather like the break declaration. Rather than forcing termination, it compels the next iteration of the loop to happen, avoiding any type of code in between.

For the for loop, continue declaration triggers the conditional test as well as increment portions of the loop to carry out. For the while as well as do … while loops, continue statement creates the program control to pass to the conditional tests.

Examples of continue statement

Example 1:-

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
for(a=1; a<=3;a++)
{
for(b=1;b<=3; b++)
{
if(a==b)
continue;
printf(" The value of a and b is%d %d\n",a,b);
}
}
getch();
}

Output:-

Example 2:-

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
for(a=1; a<=10;a++)
{

if(a==5) {
continue;
}
printf("%d\n",a);

}
getch();
}

Output:-

In the above code when the condition match, it will enter in that block and skip 5th step do to continue statement.