<<< Iteration (while loop) | Index | Iteration (for loop) >>> |
int i = 0; while ( i < 100 ) { cout << i << '\t' << square( i ) << '\n'; ++i ; // increment i }
What it takes to put together:
i // A loop variable (control variable) int i = 0; // Initialize the control variable ( i < 100 ) // A termination criterion; // here, if i<100 is false, terminate ++i // Increment the control variable cout << ... // Something to do for each iteration
<<< Iteration (while loop) | Index | Iteration (for loop) >>> |