Object-Oriented Programming (From Problem Solving to JAVA) (Charles River Media Programming)

8.1 Introduction

Most practical algorithms require a group of operations to be carried out several times. The repetition design structure is a looping structure in which a specified condition determines the number of times the group of operations will be carried out. This group of operations is called a repetition group.

There are three variations of the repetition structure, and most programming languages include them. This chapter explains three constructs to apply the three variations of the repetition structure. The constructs for repetition are:

  1. While loop

  2. Loop until

  3. For loop

The first construct, the while loop, is the most general one. The other two repetition constructs can be expressed with the while loop.

Категории