The loop statement consists of loop body and loop judgment condition, and its expression is: for (single expression; Conditional expression; End cycle) {intermediate cycle; }。
Expressions can be omitted, but semicolons cannot be omitted because ";" It can represent an empty statement. After ellipsis, the number of statements decreases, that is, the format of statements changes, which the compiler cannot recognize and compile.
Extended data
The first ";" In parentheses in the for loop. The symbol is preceded by a single expression that does not participate in the loop, which can be used as an initialization assignment statement of the variable to assign an initial value to the loop control variable; It can also be used to evaluate expressions that are not related to the for loop but are processed before the loop part.
";" The conditional expression between symbols is a relational expression, which is the official beginning of the cycle. When the conditional expression is established, the intermediate loop body is executed.
The executed intermediate loop body can be one statement or multiple statements. When there is only one statement in the middle loop body, you can omit the braces {} and execute the last loop body after the middle loop body is executed.
After the last loop body is executed, the condition will be judged again. If the condition is still true, continue to repeat the above loop, if the condition is not true, jump out of the current for loop.
Baidu encyclopedia -for loop