C continue Statement

C loops

In the C languagecontinueThe statement is somewhat likebreakStatement. But it is not a forced termination; continue will skip the code in the current loop and force the next loop to begin.

forforloop,continueAfter the statement executes, the increment statement will still execute. Forwhileanddo...whileloop,continueThe statement re-executes the conditional judgment statement.

Syntax

In C languagecontinue The syntax of statements:

continue;

Flowchart

C continue 语句

Example

Example

#include <stdio.h>
 
int main ()
{
   /* local variable definition */
   int a = 10;

   /* do loop execution */
   do
   {
      if( a == 15)
      {
         /* Skip iteration */
         a = a + 1;
         continue;
      }
      printf("value of a: %d\n", a);
      a++;
     
   }while( a < 20 );
 
   return 0;
}

When the above code is compiled and executed, it produces the following results:

a 的值: 10
a 的值: 11
a 的值: 12
a 的值: 13
a 的值: 14
a 的值: 16
a 的值: 17
a 的值: 18
a 的值: 19

C loops

other extensions