FOR
StatementChapters 3 and 4 introduced you to two control structures: sequence, in
which statements are simply written one after the other, and selection,
embodied in the IF
statement, which allows one of a set of paths
to be taken.
The third category of control structure in structured programming is
repetition, or iteration, which allows a section of a program to
be repeated, the number of repetitions being determined by some condition. In
this chapter, you will see how to specify the repetition of a group of
statements (called a counting loop) using the FOR
statement. You will study how to design counting loops in Ada programs. Two
other repetition constructs are introduced in Chapter 6.
Also in this chapter, the important concept of subtypes is extended, and you will see how using subtypes of scalar data types--integer, float, character, and enumeration--makes reading and writing programs easier and makes the programs more reliable.
Finally, two important system-structuring ideas are introduced: overloading and exception handling. Overloading permits several operations with similar behavior to be given the same name, and exception handling provides a method for keeping control when an error arises, instead of returning control automatically to the run-time system.
Copyright © 1996 by Addison-Wesley Publishing Company, Inc.