For Loop Execution Process, for loop Process
Statement format:
For (expression 1; expression 2; expression 3)
{
Loop body
}
Expression 1: Value assignment expression, which is used to assign an initial value to the control variable.
Expression 2: A logical expression is the control condition of a loop. It is used to determine whether the control variable meets the cycle condition. If yes, it enters the loop body. Otherwise, it jumps out of the loop.
Expression 3: A value expression used to increment or decrement control variables.
For Loop execution steps:
Step 1: Initialize the control variable to determine whether the control variable meets the cycle condition (expression 1-> Expression 2). If yes, it enters the loop body; otherwise, it exits the loop.
Step 2: update the control variable, perform increment or decrement operations on the control variable, and then determine whether the control variable meets the conditions (expression 3-> Expression 2). If the conditions are met, the variable enters the loop body, otherwise, exit the loop.
Step 3: Continue Step 2 until you exit the loop
# Include <stdio. h> int main () {int I; for (I = 0; I <10; I ++) {printf ("% d \ n", I );} printf ("% d \ n", I); return 0 ;}
According to the above analysis, when I does not meet the condition I <10, it jumps out of the loop (that is, when I = 10), so when I is used after jumping out of the loop, I is already 10!