SOLUTIONS TO REVIEW QUESTIONS: Chapter 3
SOLUTIONS TO DEBUGGING EXERCISES
1. *A 1 B
2
3
4
5
6
123456789012345678901234567890123456789012345678901234567890123
2. a. Incorrect. First, there is a space missing in the picture clause; it should be coded as PIC 9(5). Second, the statement MOVE SPACES TO WS-TOTAL will cause a compiler error; the figurative constant SPACES is alphanumeric, while WS-TOTAL is a numeric field. To initialize WS-TOTAL to zero, code
MOVE ZERO TO WS-TOTAL
or
MOVE 0 TO WS-TOTAL.
b. Correct. The figurative constant ZEROS may be used with both numeric and alphanumeric fields.
c. Incorrect. As the VALUE clause is presently written, the initial value of TAX-RATE will be 50.00 because the literal 0850 has an implied decimal point after its rightmost position. Assuming that the intention was to initialize the field to 08.50, then the entry should be coded
05 TAX-RATE PIC 99V99 VALUE 08.50.