continue statement in c

Written by

studymite

Continue statement

 

When continue statement found inside the loop then instead of jumping out of the loop, the next iteration of the loop takes place, skipping the statements after it.

The continue statement has simple syntax as follows:

                   
continue;

Example :

                   
 #include &ltstdio.h>
int main()
 {   
   int i; 
   for (i=0; i<=5; i++)
   {
      if (i==3)
      {
        /* The continue statement will get executed when
          the value of i is equal to 3.
         */
        continue;
       }
   /* This print statement would not execute for the
 iteration where i == 3 
*/
   printf(“%d”, i);

} return 0; }

Output :

                   
  0 1 2 4 5   
continue statement in c