The MULTIPLY statement performs multiplication operations in COBOL. It multiplies one value by another and stores the result. MULTIPLY can be used with or without the GIVING clause, and can multiply multiple fields by the same value.
1MULTIPLY multiplicand BY multiplier [GIVING result]
123456789101112131415161718192021WORKING-STORAGE SECTION. 01 AMOUNT PIC 9(5)V99 VALUE 100.00. 01 MULTIPLIER PIC 9(3) VALUE 2. 01 RESULT PIC 9(6)V99. PROCEDURE DIVISION. MULTIPLY-EXAMPLES. *> Multiply without GIVING (replaces multiplier) MULTIPLY 2 BY AMOUNT *> AMOUNT now contains 200.00 *> Multiply with GIVING (preserves originals) MULTIPLY AMOUNT BY MULTIPLIER GIVING RESULT *> RESULT = 200.00 * 2 = 400.00 *> AMOUNT and MULTIPLIER unchanged *> Multiply multiple fields MULTIPLY 1.5 BY AMOUNT RESULT *> Both AMOUNT and RESULT multiplied by 1.5 STOP RUN.
1. What does MULTIPLY do?
2. What is the difference between MULTIPLY with and without GIVING?
3. Can you multiply multiple fields at once?