Answer:

12

SUM starts out at 0, then the user enters "12", so:

  1. The calculation on the right of = is done: 0 + 12
  2. The sum 12 is saved in SUM

Adding the Second Number

Now say the program continues with the next three statements, and that the user enters "6":


' 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                 ' Second INPUT Statement
LET   SUM = SUM + NUMBER     ' Second NUMBER added to SUM
'

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 second INPUT statement will get the six and put it in NUMBER, replacing whatever was there before. Now the next LET statement:

  1. Does the calculation on the right of the = : 12 + 6
  2. Saves the answer (18) in SUM

The variables NUMBER and SUM are changed by these statements. NUMBER holds the new number input by the user. Then SUM is changed to the new total.

QUESTION 10:

Will NUMBER and SUM change when the third number is read in?