The example from the previous slide was:

Code:

sum = n = 0;
while (sum <= 1000)
{
n++;
sum += n;
}
printf("The first sum > 1000 is %d, and n is %d\n", sum, n);

Since we now know how to use the increment operators in expressions, we could get the same results by replacing the above while statement

with exactly one of the following:

Code:

while (sum <= 1000)
sum += n++;

or

Code:

while (sum <= 1000)
sum += ++n;

ALSO:

Code:

for (n = 1; n <= 50; n += 1)
printf("%8d %8d %8d\n", n, n * n, n * n * n);

What is the value of n for the above for loop?