continue
This statement is used
to skip a part of loop for the current iteration and continue with the next
iteration. This can be used within while, do-while, for. A continue statement ends the current
iteration of a loop. Program control is passed from the continue
statement to the end of the loop body. A continue statement can only appear within the
body of an iterative statement. The continue statement ends the processing of the
action part of an iterative (do, for, or while) statement and moves control
to the loop continuation portion of the statement. For example, if the
iterative statement is a for statement,
control moves to the increment or update section and then to the test condition
part of the loop.With in nested statements, the continue statement ends only the current
iteration of the do, for, or while statement immediately
enclosing it.
Syntax:-
continue;
Sample
program to illustrate the break statement in single loop.
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
clrscr();
for(i=1;i<=6;i++)
{
printf("%d",i);
if(i>=3)
continue;
printf("hello \n");
}
printf("Out of loop..");
getch();
}
Output
1hello
2hello
3
4
5
6
Out of loop..
No comments:
Post a Comment