Continue Statement in C
continue jump statement, is used in loops with if condition to skips or jumps the current iteration or loop cycle.
continue with for
#include<stdio.h>
void main()
{
for(int i = 0; i < 10; i++)
{
if(i == 5)
{
continue;
}
printf("%d ", i);
}
}
continue with while loop
#include<stdio.h>
void main()
{
int i = 0;
while(i < 5){
if(i == 3){
continue;
}
i++;
}
}
continue with for do while loop
void main()
{
int i = 0;
do{
if(i == 3){
continue;
}
i++;
}while(i < 5);
Explanation
When value of i becomes 5, if condition inside loops become true and continue will skip the current loop cycle.