Break And Continue Statements In C Language
break statement();
When a break statement is encountered inside a while, for, do/while or switch statement the statement is immediately terminated and execution resumes at the next statement following the statement.
For Example :-
Syntax
...
for ( x = 1 ; x <= 10 ; x++ )
{
if ( x > 4 )
break ;
printf( “%d “ , x ) ;
}
printf( "Next executed\n" );
//Output : “1 2 3 4 Next Executed”
...
continue statement() :
The continue statement terminates the current iteration of a while, for or do/while statement and resumes execution back at the beginning of the loop body with the next iteration.
For Example :-
Syntax
...
for ( x = 1; x <= 5; x++ )
{
if ( x == 3 )
continue ;
printf( “%d “, x ) ;
}
printf( “Finished Loop\n” ) ;
// Output : “1 2 4 5 Finished Loop”