MainframeMaster
MainframeMaster

COBOL Tutorial

Progress0 of 0 lessons

COBOL MULTIPLY Statement

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.

Basic Syntax

cobol
1
MULTIPLY multiplicand BY multiplier [GIVING result]

Examples

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
WORKING-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.

Test Your Knowledge

1. What does MULTIPLY do?

  • Divides numbers
  • Multiplies two values
  • Adds numbers
  • Subtracts numbers

2. What is the difference between MULTIPLY with and without GIVING?

  • No difference
  • GIVING preserves original values, without GIVING replaces multiplier
  • GIVING is faster
  • GIVING only works with integers

3. Can you multiply multiple fields at once?

  • No, only one at a time
  • Yes, by listing multiple fields
  • Only with GIVING
  • Only with literals

Related Concepts

Related Pages