Answer:
There is no limit. As long as the user does not enter a 0,the program is happy to keep adding.This is a big advantage.Often you want a program to run until you tell it to stop.(Much like a car—you want it to keep running untilyou are done with it. It would be awkward if you had to tellyour car exactly how far you wanted it to go at the beginningof each trip.)
A big advantage of using sentinel values is that there isno limit to how many times a loop can execute,and that it ends gracefully when it is done.
If the user keeps entering big numbers, soon the sum willbe too large for the computer to handle.This is just like a hand calculator that has a limit on howlarge a number it can hold.But if the user were entering both negative and positive numbers,the sum might never get too large.Then the program could keep going and going.
Other Sentinel Values
A sentinel value should be a value that is never going toappear in data.Adding zero to a sum does not change the sum,so the program to add numbers could use zero as a sentinel value.If the list of numbers the user were adding had a zero in it,the user could just skip it without changing the sum.
Sometimes you know that there will never be any negativenumbers in a list of numbers to add.The program could be changed so that any negative numberacted as a sentinel value.Here is the program, with a blank in the loop condition:
' Add up numbers that the user enters.' When the user enters any negative number, ' print the sum and end the program.'LET SUM = 0'PRINT "Enter a positive number" INPUT NUMBER 'DO WHILE NUMBER ______ 0 LET SUM = SUM + NUMBER PRINT "Enter a positive number." INPUT NUMBER LOOP'PRINT "The sum is", SUMEND