Continue Statement in C

by Yogesh Khanna 23-Aug-18

0 738


The continue statement in c program helps in continuing the loop when an unexpected condition occurs, it passes the control to the starting of the loop.
The syntax of continue statement in c program is as follows:

continue;

The example of continue statement in c program is as follows:

#include <stdio.h>
int main(){
int i=1;
// starting a loop from 1 to 10
for(i=1; i<=10; i++){
if(i==5)

{ // if value of i is equal to 5, it will continue the loop
continue;
}
printf("%d\n", i);
} // end of for loop
return 0;
}
Result:
1
2
3
4
6
7
8
9
10

Note: As you can notice 5 is not printed on the result as the loop is continued at i=5.

Share:


Comments

    Waiting for your comments

Leave a Reply