The function of the continue statement in C language is to skip the remaining part of the loop and directly continue executing the next round of loop. Usage: 1. Can only be used in loop structures; 2. The statement is placed at the position that needs to be skipped; 3. The effect is to skip the remaining statements and go to the next iteration.
Usage of continue in C language
The continue statement is a control flow statement in C language. Used to skip the remainder of the loop and continue directly to the next iteration of the loop.
Usage:
continue statement can only be used in loop structures (for, while, do-while). It is placed where the remainder of the loop needs to be skipped.
Effect:
When a continue statement is encountered, the remaining statements in the loop will be skipped, and the program will go directly to the next iteration of the loop.
Example:
<code class="c">for (int i = 0; i < 10; i++) { if (i % 2 == 0) { continue; } printf("%d\n", i); }</code>
In this example, the continue statement is used to skip even numbers. Therefore, the output will be:
<code>1 3 5 7 9</code>
Note: The
The above is the detailed content of How to use continue in C language. For more information, please follow other related articles on the PHP Chinese website!