IMPLEMENTATION OF SUBROUTINES IN COBOL


  THIS IS MAIN PROGRAM.
       IDENTIFICATION DIVISION.
       PROGRAM-ID."MAIN".
       AUTHOR."KUNAL"
       DATE-WRITTEN."27/02/12".
       DATE-COMPILED."27/02/12".
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SOURCE-COMPUTER. M8.
       OBJECT-COMPUTER. M8.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       77 A PIC 99.
       77 B PIC 99.
       PROCEDURE DIVISION.
           START1-PARA.
        DISPLAY "enter values of a & b".
        ACCEPT A.
        ACCEPT B.
         CALL "----calling subroutine----".
        CALL "ADD" USING A,B.
        CALL "SUBTRACT" USING A,B.
        CALL "MULTIPLY" USING A,B.
        CALL "DIVIDE" USING A,B.
         CALL "----subrotine called-----".
         STOP RUN.
------------------------------------------------------
THIS IS ADD SUBROUTINE named "ADD.COB"

       IDENTIFICATION DIVISION.
       PROGRAM-ID."ADD".
       AUTHOR."KUNAL"
       DATE-WRITTEN."26/02/12".
       DATE-COMPILED."26/02/12".
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SOURCE-COMPUTER. M8.
       OBJECT-COMPUTER. M8.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       77 Z PIC 999.
       LINKAGE SECTION.
       77 X PIC 99.
       77 Y PIC 99.
       PROCEDURE DIVISION USING X Y.
       COMPUTE Z = X + Y.
       DISPLAY " SUM = " Z.
       EXIT PROGRAM.
--------------------------------------------------------
THIS IS SUBTRACT SUBROUTINE named "SUBTRACT.COB"

       IDENTIFICATION DIVISION.
       PROGRAM-ID."SUBTRACT".
       AUTHOR."KUNAL"
       DATE-WRITTEN."26/02/12".
       DATE-COMPILED."26/02/12".
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SOURCE-COMPUTER. M8.
       OBJECT-COMPUTER. M8.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       77 J PIC 99.
       LINKAGE SECTION.
       77 K PIC 99.
       77 L PIC 99.
       PROCEDURE DIVISION USING K L.
       COMPUTE J = K - L.
       IF K > L
        DISPLAY " DIFFERNCE = " J
       ELSE
        DISPLAY "DIFFERENCE = -" J.
       EXIT PROGRAM.
---------------------------------------------------------
THIS IS MULTIPLY SUBROUTINE named "MULTIPLY.COB"

        IDENTIFICATION DIVISION.
       PROGRAM-ID."MULTIPLY".
       AUTHOR."KUNAL"
       DATE-WRITTEN."26/02/12".
       DATE-COMPILED."26/02/12".
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SOURCE-COMPUTER. M8.
       OBJECT-COMPUTER. M8.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       77 P PIC 9999.
       LINKAGE SECTION.
       77 Q PIC 99.
       77 R PIC 99.
       PROCEDURE DIVISION USING Q R.
       COMPUTE P = Q * R.
       DISPLAY " PRODUCT = " P.
       EXIT PROGRAM.
-----------------------------------------------------------
THIS IS DIVIDE SUBROUTINE named "DIVIDE.COB"

        IDENTIFICATION DIVISION.
       PROGRAM-ID."DIVIDE".
       AUTHOR."KUNAL"
       DATE-WRITTEN."26/02/12".
       DATE-COMPILED."26/02/12".
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SOURCE-COMPUTER. M8.
       OBJECT-COMPUTER. M8.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       77 M PIC 99.
       LINKAGE SECTION.
       77 N PIC 99.
       77 O PIC 99.
       PROCEDURE DIVISION USING N O.
       COMPUTE M = N / O.
       DISPLAY " QUOTIENT = " M.
       EXIT PROGRAM.











Previous
Next Post »