COBOL Program to Add Two Numbers.
Dear students please go through the program and do comment for doubts.

123456789012345678901234567890123456789012345678901234567890123456789012
       IDENTIFICATION DIVISION.
       PROGRAM-ID. SUM-OF-TWO-NUMBERS.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SOURCE-COMPUTER.
       OBJECT-COMPUTER.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  NUM1    PIC S999V99.
       01  NUM2    PIC S999V99.
       01  TOTAL   PIC S9(4)V99.
       01  E-TOTAL PIC ----9.99.
       01  HAI     PIC PP999.
       01  E-HAI   PIC ZZZ.9(8).
       PROCEDURE DIVISION.
       MAIN-PARA.
           DISPLAY(01 01) SPACES.
           DISPLAY(05 05) "Enter the First Number : ".
           ACCEPT(05 32) NUM1.
           DISPLAY(07 05) "Enter the Second Number : ".
           ACCEPT(07 32) NUM2.
           COMPUTE TOTAL = NUM1 + NUM2.
           MOVE TOTAL TO E-TOTAL.
           DISPLAY(10 05) "The Sum = " E-TOTAL.
           DISPLAY(11 05) "====================".
           DISPLAY " ".
           MOVE 12 TO HAI.
           MOVE HAI TO E-HAI.
           DISPLAY E-HAI.
           STOP RUN.

No comments:

Post a comment