program 1
10 REM FIND THE ANSWER TO TEN SUBTRACTION PROBLEMS
20 LET I=1
30 READ A,B
40 LET C = A-B
50 PRINT A,B,C
60 LET I = I + 1
70 IF I $lt 11 THEN 30
80 DATA 10,6,15,9,12,7,14,5,18,9
90 DATA 11,3,6,2,13,7,6,3,9,1
100 END
Results:
Explanation—program 1
-
Line 20 This begins the counting for the ten problems.
-
Line 30 “READ” will read the numbers in the “DATA” by assigning values to the variables.
-
Line 60 Tells the computer to do the next problem.
-
Line 70 “IF” tells the computer that if under eleven problems have been done then continue. Once ten problems are complete the program will end.
Line 80 “DATA” assigns values to the variables.
90
program 2
10 REM SUBTRACT TO FIND THE DIFFERENCE
20 READ A,B
30 LET C = A - B
40 PRINT A,B
50 PRINT “WHAT IS THE DIFFERENCE?”
60 INPUT C1
61 PRINT C1
70 IF C1 = C THEN 90
80 PRINT “SORRY, TRY THE NEXT ONE”
84 PRINT
85 GO TO 20
90 PRINT “VERY GOOD”
99 PRINT
100 GO TO 20
110 DATA 16,9,12,4,10,5,8,6,15,7
120 END
Results:
WHAT IS THE DIFFERENCE?
7
VERY GOOD
WHAT IS THE DIFFERENCE?
9
SORRY, TRY THE NEXT ONE
Explanation—program 2
Line 70 If the answer that was typed into the terminal was correct then “VERY GOOD” would be printed. If the answer was incorrect “SORRY, TRY THE NEXT ONE” would be printed. Only one try is given to find the answer and then the next problem appears.
Line 84 “PRINT” with nothing after it will allow for a blank space in the results. I used it so the results would be easier to read.