C Continue statement


C Continue Statement


In some programming situations we want to take the control to the beginning of the loop, bypassing the statements inside the loop, which have not yet been executed.
The keyword continue allows us to do this. When continue is encountered inside any loop, control automatically passes to the beginning of the loop.

The working structure of 'continue' is similar as that of that break statement but difference is that it cannot terminate the loop. It causes the loop to be continued with next iteration after skipping statements in between. Continue statement simply skipps statements and continues next iteration.


Syntax :

continue;


Example :


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

void main()
{
int i;
clrscr();
for<(i=1; i<=5; i++)
{
if(i==3) continue;
printf("\n\t %d",i); // 3 is omitted
}
getch();
}

Output :








Description :


The for loop executes normaly from i=1 to i=5, and display the respective values as output ,but when the value of i become 3, the continue statement executes which omit the printing of the value i=3.

     Prev                                                   NEXT

0 comments:

Post a Comment