The execution sequence of the for loop.
Review the basic records and record the execution sequence of this for loop:
For (expression 1; expression 2; expression 3)
{Loop body}
Step 1: First assign an initial value to expression 1;
Step 2: Determine whether expression 2 meets the given conditions. If its value is true and the loop condition is met, execute the statement in the loop body, then execute expression 3, and then enter the second loop. If the value of expression 2 is false, The for loop is terminated and the in vitro statement of the loop is executed.
Example 1
Int main (int argc, char * argv []) {for (inti = 0; I <5; I ++) cout <I <"\ t "; return0;}/* He asked hovertree.com */
The output is 0, 1, 2, 3, 4.
Example 2
Int main (int argc, char * argv []) {int I = 0; for (I = 0; I <5; I ++) cout <I <"\ t"; cout <I <"\ t"; return 0;}/* Ask hovertree.com */
The output is 0, 1, 2, 3, 4, 5.
Recommended:
Http://www.cnblogs.com/roucheng/p/cpptimu.html