Continue Statement in C


Prev Tutorial Next Tutorial

Continue Statement in C

C Continue statement are used to skips the rest of the current iteration in a loop and returns to the top of the loop. The continue statement works like a shortcut to the end of the loop body.

Use break statement

Syntax

jump-statements (loop or switch case);
continue; 

Example of continue

#include<stdio.h>
#include<conio.h>

void main()
{    
int i=1;  
clrscr();    
  
for(i=1; i<=10; i++) 
{    
if(i==3)  //if value of i is equal to 3, it will continue the loop 
{  
continue;  
}  
printf("%d \n",i);  
}//end of for loop  
  
getch();    
}

Output

1
2
4
5
6
7
8
9
10

Prev Tutorial Next Tutorial

Advertisements




Facebook Likes

Advertisements