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