Continue Statement in C

In this tutorial, You learn about the continue statement in C. Also learn the use of continue statement in C with the help of C example.

The Continue Statement in C is the same as the break statement in C which we learned about break statement in the previous tutorial. Both the C continue and break are used to skip the block of code. Thus both statements are also known as Jump statements.

But you ask "Both are the same then what is the difference if both jump statements? ". In the upcoming tutorial, I will share the difference between continue and break in C language. Below I shared all details with the help of syntax, flowchart, and examples.

C Continue

The Continue statement in C is somewhat different from the break statement. The continue force causes the control to test expression and starts the next iteration of the loop and skip rest of the code.

Use of continue Statement

The use of continue in terms of for loop, the next iteration takes place with increase the iterator and test for expression. For while loop and do...while loop the continue statement cause the control to go directly to the test expression.

Syntax

The syntax for continue statement in C as follow

continue;

Flowchart

The following flowchart explains the working of continue statement in C

continue statement in C

Example

#include <stdio.h>
int main()
{
   int i=0;
   while(i<10)
   {
      if (i%2==0)
      {
         i++;
         continue;
      }
      printf("%d ", i);
      i++;
   }
   return 0;
}

Output


  1 3 5 7 9

From above you learn to continue statement in C. Also learn the use of continue statement in C with the help of C example.

Happy Coding 😊

If you have any doubts, Please let me know

Previous Post Next Post

Contact Form