Revised 10/04/98, 08/08/99, 01/20/00

CHAPTER 18 --- Sentinel Controlled Loops

The previous several chapters have discussed loops, and counting loops in particular. The same statements that are used to build counting loops can be used to build other kinds of loops. This chapter will look at a kind of loop called a sentinel controlled loop.

Chapter Topics:

  • Sentinel-controlled loops.
  • Example programs: adding up a list of integers, and evaluating polynomials.
  • Using an if-else statement inside the loop body.
  • Matching up if's with else's.
  • Using a String value as a sentinel.

QUESTION 1:

Say that a program is to add up a list of numbers entered by the user from the keyboard. Will a loop be used in this program?

Click Here after you have answered the question