For (statement1; Statement 2; Statement 3)
When executing, first execute the statement 1 (note that it is only executed once).
Then, it is judged whether statement 2 holds.
1. If an execution loop is established, execute statement 3. Return to statement 2 to determine whether the condition is true? Execute statement 3 after the loop body is established, so jump out of the loop until the loop body is not established.
2. If statement 2 does not hold, jump out of the loop directly and do not execute the loop body or statement 3.
Extended data:
Other uses of for loop editing
1 and for loops can have multiple levels of nesting. Example:
# include & ltstdio.h & gt
int main(void)
{
int i,j,k;
printf(" ijk \ n ");
for(I = 0; I<2; i++)?
for(j = 0; j & lt2; j++)?
for(k = 0; k & lt2; k++)
printf("%d%d%d\n ",I,j,k);
Returns 0;
}
The output result is: ijk00000101001011165438.
2. The life cycle of variables in the 2.for loop is a loop iteration.
# include & ltstdio.h & gt
int main(void)
{
int I;
for(I = 0; I<9; i=i+ 1)
{
int a = I;
printf("%d\n ",a);
}
Returns 0;
}
Variables in the C statement must be declared before they can be used, and it is illegal to use variables before defining the statement.
References:
Baidu encyclopedia -for loop