Studying for Quiz 4? - Review Chapter 5

Quiz 4 covers Chapter 5 of the Friedman & Koffman text: "Repetition and Loop Statements", and includes the for loop (Section 5.3).

Another aspect of the for loop which is relevant to Quiz 5 is its use in converting a series summation (S) or a series multiplication (P) into C code. Thus for example, the series summation:

could be represented by the following for loop:

int sum = 0;
for(int i = 1; i <= n; i++)
   sum = sum + i*i; // also: sum += i*i;

Furthermore, as another example, the series multiplication:

which is another way of defining n! (factorial of n), and could be represented by the following for loop:

int mult = 1;
for(int i = 1; i <= n; i++)
   mult = mult*i; // also: mult *= i;

Be sure to understand these new usages of the for loop. We will have many more examples of these once we study arrays.

Telnet: "condor"