Simple Question from Stupid Person...
Hi. I have a series of question about a simple hypothetical program. It is part of a test-review sheet, and I can't figure it out for the life of me:
Here's the sim-program:
SUB N1 # subtracts N1 from what's on scratch-pd
IFPOS A # if s-pad is pos, go to A
LOAD N1 # load N1 to s-pad
A LOAD N2
N1 INIT 0
N2 INIT 0
Here are the questions:
(a) If you run this and submit the numbers 1O and 3O in that order, what value will be printed?
(b) If you run this and submit 10 and 3 in that order, what value will print?
(c) How could you phrase in plain English what this program does?
(d) Sketch out a program that will read a sequence of numbers and print the value of how many numbers there were. "Read" should stop when the number 0 is read. This 0 will not be included in the count.
(e) Write the code for a program that prints the numbers 1, 2, 3, ..., and will loop infinitely.