Continue Statement in C
0 3191
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 the continue statement in C program:
continue;
Example:
#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