Yes.
Now the program continues with the third group of statements. Say that the user enters "5":
' Ask the user for numbers. ' Add them up, print the sum. ' LET SUM = 0 ' Clear the sum ' PRINT "Enter a number" ' First number INPUT NUMBER ' User enters first number LET SUM = SUM + NUMBER ' increase the SUM ' PRINT "Enter a number" ' Second number INPUT NUMBER LET SUM = SUM + NUMBER ' PRINT "Enter a number" ' Third number INPUT NUMBER LET SUM = SUM + NUMBER ' PRINT "The total is:", SUM ' At this point, SUM is the total of all numbers ' END
The "5" is input into NUMBER
, then it is added to SUM
.
So SUM ends up with 23 in it.
Finally the PRINT
statement prints out the answer.
Now say that you wanted a program that added up 10 numbers. How could you write it? (Just think about it)