Multiply Verb in COBOL

Multiply Verb

Multiply verb is used to multiply the numeric items.

Following is the syntax of multiply two or more numbers:
MULTIPLY A BY B C     ----- Syntax 1

MULTIPLY A BY B GIVING E   ----- Syntax 2

In syntax 1, A and B are multiplied and the result is stored in B i.e B (B=A*B). A and C are multiplied and the result is stored in C. (C=A*C).

In syntax 2, A and B are multiplied and the result is stored in E. i.e (E=A*B)

Example : Demonstration of multiply verb

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 WS-N1 PIC 9(2) VALUE 12 .
   01 WS-N2 PIC 9(3) VALUE 3.
   01 WS-N3 PIC 9(4) VALUE 5.
   01 WS-NA PIC 9(3) VALUE 15.
   01 WS-NB PIC 9(3) VALUE 15.
   01 WS-NC PIC 9(3) VALUE 5.

PROCEDURE DIVISION.
   MULTIPLY WS-N1 BY WS-N2 WS-N3.
   MULTIPLY WS-NA BY WS-NB GIVING WS-NC.
   
   DISPLAY "WS-NUMBER-1     : " WS-N1
   DISPLAY "WS-NUMBER-2     : " WS-N2
   DISPLAY "WS-NUMBER-3     : " WS-N3
   DISPLAY "WS-NUMBER-A     : " WS-NA
   DISPLAY "WS-NUMBER-B     : " WS-NB
   DISPLAY "WS-NUMBER-C     : " WS-NC
   
STOP RUN.


Output:
WS-NUMBER-1     : 12
WS-NUMBER-2     : 036
WS-NUMBER-3     : 0060
WS-NUMBER-A     : 015
WS-NUMBER-B     : 015
WS-NUMBER-C     : 225