No, probably not.
Sometimes the user is asked explicitly
if the loop should continue.
The user enters "yes" or "no" (or maybe "y" or "n").
Now the sentinel is of type String
or char
.
The next example illustrates this:
Say that you were interested in the value of the polynomial:
7x3- 3x2 + 4x - 12
for various values of x. The value x is a double precision value. For example, when x == 2.0 the polynomial is equal to:
7*23- 3*22 + 4*2 - 12 = 7*8 - 3*4 + 8 - 12 = 40
The program lets the user enter various values for x and see the result for each one.