Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

C continue Statement

C continue Statement

C Loops C Loops

In C, the continue continue statement in C++ is somewhat like the break statement. But it is not a forced termination; continue skips the code in the current loop and forces the start of the next iteration.

For for a for loop, thecontinue After the statement executes, the increment statement still executes. For while and do...while a for loop, thecontinue statements, the condition statement is re-executed.

Syntax

The syntax of the **continue ** statement in C:



continue;

Flowchart

Example

Example

#include

 

int

main

(

)

{

   

/* Local variable definition */

   

int

a

=

10

;

   

/* do loop execution */

   

do

   

{

     

if

(

a

==

15

)

     

{

         

/* Skip the iteration */

         a

=

a

1

;

         

continue

;

     

}

     

printf

(

"Value of a: %d\n"

, a

)

;

      a

++

;

     

   

}

while

(

a

<

20

)

;

 

   

return

0

;

}

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



a 的值: 10

a 的值: 11

a 的值: 12

a 的值: 13

a 的值: 14

a 的值: 16

a 的值: 17

a 的值: 18

a 的值: 19

C Loops C Loops