June 2006
Intermediate to advanced
1344 pages
42h 52m
English
This section uses the While repetition statement introduced in Chapter 5 to highlight the elements required to perform counter-controlled repetition. Counter-controlled repetition requires
the name of a control variable (or loop counter) that is used to determine whether the loop continues to iterate
the initial value of the control variable
the increment (or decrement) by which the control variable is modified each time through the loop
the condition that tests for the final value of the control variable (i.e., whether looping should continue)
The example in Fig. 6.1 uses the four elements of counter-controlled repetition to display the even integers in the range 2–10. The declaration in line 5 ...
Read now
Unlock full access