
The basic attribute of an iteration control structure is to be able to repeat some lines of code. The visual display of iteration creates a circular loop pattern when flowcharted, thus the word "loop" is associated with iteration control structures. Iteration can be accomplished with test before loops, counting loops, and test after loops. A question using Boolean concepts usually controls how long the loop will execute.
We have mentioned that the while control structure belongs to the iteration category and is a test before loop.
Example 10.2: while control structure
counter = 0; while (counter < 5) { cout « "\nI love computers!"; counter ++; }
- 瀏覽次數:6833