MULTIPLY with Giving
MULTIPLY with Giving Example
Scenario - Multiply two varibles and places the result into other variable.
Code -
----+----1----+----2----+----3----+----4----+----5----+
IDENTIFICATION DIVISION.
PROGRAM-ID. MULTGIVN.
AUTHOR. MTH.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-VAR.
05 WS-V1 PIC 9(02) VALUE 20.
05 WS-V3 PIC 9(02) VALUE 10.
05 WS-V4 PIC 9(03).
PROCEDURE DIVISION.
* Multiply with GIVING
MULTIPLY WS-V1 BY WS-V3
GIVING WS-V4
END-MULTIPLY.
DISPLAY "WS-V4: " WS-V4.
STOP RUN.
Output -
WS-V4: 200
Explaining Example -
In the above example:
- It defines three variables: WS-V1 with a value of 20, WS-V3 with a value of 10, and WS-V4.
- It performs a multiplication operation on WS-V1 and WS-V3 using the MULTIPLY statement, and the result is stored in WS-V4 using the GIVING clause.
- Finally, it displays the value of WS-V4.