Next: Exercises
Up: The for statement
Previous: Multiple Choice Questions
int i; for ( i = 1; i <= 12; i *= 2 ) cout << i << endl;
for statement.
int i;
for (i=1; i<20; i = i+3)
cout << i << endl;
What would happen if the i+3 in the update expression was changed to
i-3?for statement to output the numbers 1 to 20, each on a new
line.for statement which accepts
n real values entered by a user and outputs their average value.
Assume n will be greater than zero.while statement first, then
repeat using a do-while statement and finally repeat using a
for statement.