continue statement in c

The continue statement is used inside loops. When a continue statement is encountered inside a loop, control jumps to the beginning of the loop for next iteration, skipping the execution of statements inside the body of loop for the current iteration.

  • The continue statement is used inside loops in C Language. When a continue statement is encountered inside the loop, control jumps to the beginning of the loop for next iteration, skipping the execution of statements inside the body of loop after continue statement.
  • It is used to bring the control to the next iteration of the loop.
  • The continue statement skips some code inside the loop and continues with the next iteration.
  • It is mainly used for a condition so that we can skip some lines of code for a particular condition.
  • It forces next iteration in loop i.e. as break terminates the loop but continue forces the next iteration of the loop.

Syntax :

Continue;

Flow Diagram of Continue Statement in c:

Examples of Continue Statement :

#include <stdio.h>
int main()
{
   for (int j=0; j<=8; j++)
   {
      if (j==4)
      {
	    /* The continue statement is encountered when
	     * the value of j is equal to 4.
	     */
	    continue;
       }

       /* This print statement would not execute for the
	* loop iteration where j ==4  because in that case
	* this statement would be skipped.
	*/
       printf("%d ", j);
   }
   return 0;
}

Leave a Comment

Your email address will not be published. Required fields are marked *

//sticy ads