Latest web development tutorials

C continue statement

C cycle C cycle

C language statementscontinue a bit like a breakstatement. But it is not forced to terminate, continue will skip the current code in the loop, forced to start a next cycle.

For thefor loop,continue increment statement after executing the statement will still be executed. Forwhile and do ... whileloop, continue statement? Re-execute the conditional statement.

grammar

Continue statement in C language syntax:

continue;

flow chart

C continue statement

Examples

#include <stdio.h>
 
int main ()
{
   /* 局部变量定义 */
   int a = 10;

   /* do 循环执行 */
   do
   {
      if( a == 15)
      {
         /* 跳过迭代 */
         a = a + 1;
         continue;
      }
      printf("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 cycle C cycle