A good answer might be:Yes; each iteration of the loop will add a new number to the sum. | |
Program to Add up User-entered IntegersThe loop will add each integer the user enters to a sum. A counting loop could do this if we knew how many integers were in the list. But often users don't know this in advance, or would find it annoying to find out. (If you have a column of integers, you would like to add them one by one until you reach the last one. It would be annoying if you needed to count them first.) The idea of a sentinel controlled loop is that there is a special value (the "sentinel") that is used to say when the loop is done. In this example, the user will enter a zero to tell the program that the sum is complete. The general scheme of the program is given below:
| |
QUESTION 2:It would be really good if you got out a scrap of paper and tried to complete this program. Lacking that, mentally decide what should should go inside the loop body. Click Here after you have answered the question |