Previous | Next | Table of Contents | Index | Program List | Copyright

CHAPTER 5

Repetition in Programs


5.1 Control Structures: Counting Loops and the FOR Statement
5.2 Problem Solving: Generalizing a Solution
5.3 Problem Solving: Repeating a Program Body
5.4 Control Structures: Nested Loops
5.5 Continuing Saga: Nice Spider Patterns
5.6 Data Structures: Subtypes of Scalar Types
5.7 Tricks of the Trade: Debugging and Regression Testing
5.8 System Structures: A Useful Functions Package and the Overloading Principle
5.9 System Structures: Introduction to Exception Handling
5.10 Tricks of the Trade: Common Programming Errors
Chapter Review

Chapters 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.


Previous | Next | Table of Contents | Index | Program List | Copyright

Copyright © 1996 by Addison-Wesley Publishing Company, Inc.