if-else
statement inside the loop bodyif
's with else
'sThe previous chapters have discussed loops in general, and counting loops in particular. The same statements that are used to build counting loops are used to build all other kinds of loops. This chapter looks at a kind of loop called a sentinel controlled loop, where the loop ends when a particular value occurs..
Say that you want a program that adds up any number of integers entered from the keyboard. Will a loop be used in this program?