SOLUTIONS TO REVIEW QUESTIONS:  Chapter 7  

II. General Questions 

 
 

A = 3, B = 2, X = 5

(PIC for each is 99V99)

 

COBOL Statement

Result In

Contents

1.

ADD A B GIVING X

X

05Ù 00

2.

ADD A B TO X

ON SIZE ERROR

MOVE ZERO TO X

X

10Ù 00

3.

DIVIDE A INTO B ROUNDED

B

00Ù 67

4. MULTIPLY MPG BY GAS GIVING MILES-TRAVELED

5. COMPUTE Y = (A + B) ** 2 / X

6. Correct.

7. The receiving field cannot be a literal.

8. AMT cannot be followed by a period. Only with a COBOL 85 compiler can both TO and GIVING be used in the same ADD statement.

9. DIVIDE and MULTIPLY operations cannot be performed inthe same statement. It should be:
              DIVIDE A BY B
              MULTIPLY B BY C

10. ROUNDED must appear to the left of the equal sign in a COMPUTE statement.