FIT100
World Famous Iteration
To loop
n
times the WFI has this form
•
for ( i=0; i<n;
i++) {
•
<
statement list
>
•
}
•
•
Advantages:
•
Fast to type
•
The number of iterations is the number after
<
•
0-origin makes it handy for most computations
WFI starts at 0, steps
by 1, stops (before) n
0, 1, 2, …, n-1
Same as i=i+1