Chapter 4

1. (a) The word DO marks the beginning of a loop.
(b) The word LOOP marks the end of a loop.

2. (a) The word THEN marks the beginning of the first branch.
(b) The word ELSE marks the beginning of the second branch.

3. (a) (1 = 1) is true.
(b) (2 > 7) is false.
(c) ("AA" <> "AB") is true.
(d) (2 < 7) is true.

4. Assume X = 1 and Y = 2.

(a) (X + 1 = Y) is true.
(b) (X = Y + 1) is false.
(c) (Y <> 2 * X) is false.
(d) (not (X = Y)) is true.
(e) ((X = 3) or (Y > 1)) is true.
(f) (X <> Y + 1) and (X + 1 = Y)) is true.

5. The statement "LOOP until X = 0" checks for further
looping at the bottom of the loop.

6. The DO WHILE statement is generally preferable to the
EXIT DO statement as a test for exiting a loop.

7. Press the interrupt key to stop an infinite loop.

8. A step size of +1 is assumed if a step value is not
specified.

9. If the step is positive, a FOR loop executes once when the
lower limit is equal to the upper limit. It does not execute if
the lower limit is greater than the upper limit.

10. Variable I has a value of 7 after the loop stops.

11. The loop will not execute because the step is negative and
the lower limit is less than the upper limit.

12. The word ELSE is required only if the IF statement has an
explicit second branch.

13. The statement END IF is valid, but the statement ENDIF is
not allowed.

14. The statements ELSE IF and ELSEIF are both valid.

15. This program displays the letter A when the Return key
is pressed.

16. If the variable Result has a value of 5 in the statement
"SELECT CASE Result", the results of CASE tests are:

(a) (CASE 1, 3, 6) is false.
(b) (CASE 1 to 6) is true.
(c) (CASE is > 1) is true.
(d) (CASE is < 5) is false.

17. The logical value of MORE DATA is true and that of END
DATA is false before the first READ statement is executed.

18. A program must store the count of the number of numeric
values that are read, as well as calculate and store the sum of these
values.

19. If a variable Store is to hold the largest number in a
sequence, it should be given the smallest possible initial value;
for example, the negative value of the system variable Maxnum.

20. If a variable Store is to hold the smallest number in a
sequence, it should be given the largest possible initial value;
for example, the value of the system variable Maxnum.

21. The RESTORE statement sets the data pointer to point at the
first data item in the first DATA statement.