February 2017
Beginner
1056 pages
28h 57m
English
The cautious seldom err.
—CONFUCIUS
A loop typically involves three elements: the initializing statements that must precede any repetition, the loop body, and the mechanism for ending the loop. In this section we give you techniques for designing each of these loop components. Although the initializing statements come before the loop body, the loop body is naturally designed first, and so we will start our discussion there.
One way to design a loop body is to write out the sequence of actions that you want your code to accomplish. For example, you might write the following actions:
Display instructions to the user.
Initialize variables.
Read a number ...
Read now
Unlock full access