' ADDTHEM2.BAS
' This program reads and adds values stored in DATA statements
'   until an end-of-data marker (-9999) is detected.

CLS

DO WHILE (number! <> -9999)     ' loop until end-of-data marker read
    READ number!                ' assign next DATA item to number!
    IF (number! <> -9999) THEN  ' if not end-of-data marker then
        sum! = sum! + number!   '   keep a running total
        items% = items% + 1     '   count the number of values read
    END IF
LOOP

PRINT "The sum of the"; items%; "numbers is"; sum!

DATA 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
DATA 88.2, 25, 3.3, 100, -74.2, 0, 20, 0.34, -89, 5.4567
DATA -9999

