The continue Statement in C Language



Sometimes there arises a situation where we don’t want to execute the certain statements within the loop but we want to continue the execution of the loop till the condition is satisfied. This can be done using continue statement.
Consider the below example,
for(i=0;i<10;i++){
/*statement1*/
/*statement2*/
/*statement3*/
/*statement4*/
}
Let us suppose that, when the value of i equals to 5 we want to skip the execution of statement3 and statement4. Then, we can use the continue statement to perform the above task as follows.
for(i=0;i<10;i++){
/*statement1*/
/*statement2*/
if(i ==5)
continue;
/*statement3*/
/*statement4*/
}
Here, when value of i equals to 5, statement3 and statement4 are skipped and control gets transferred to the increment part of for loop and for loop is executed as normal.


Responses

0 Respones to "The continue Statement in C Language"

Post a Comment

 

Total Pageviews

Return to top of page Copyright © 2011 | Kuppam Engineering College Converted into Blogger Template by Mohan Murthy