Advertisement
nr0q

Long Addition

Dec 6th, 2023 (edited)
3,648
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
COBOL 1.18 KB | None | 0 0
  1.        IDENTIFICATION DIVISION.
  2.        PROGRAM-ID. LONG-ADDITION.
  3.  
  4.        ENVIRONMENT DIVISION.
  5.        CONFIGURATION SECTION.
  6.  
  7.        DATA DIVISION.
  8.        FILE SECTION.
  9.  
  10.        WORKING-STORAGE SECTION.
  11.        01 START-TIME        PIC 9(10) COMP.
  12.        01 END-TIME          PIC 9(10) COMP.
  13.        01 TIME-ELAPSED      PIC 9(10) COMP.
  14.        01 NUM1              PIC 9(4) VALUE 2.
  15.        01 NUM2              PIC 9(4) VALUE 2.
  16.        01 RESULT            PIC 9(4).
  17.        01 COUNTER           PIC 9(10) VALUE ZERO.
  18.        01 MEMORY-LEAK       PIC X(1000000).
  19.  
  20.        PROCEDURE DIVISION.
  21.        BEGIN.
  22.            PERFORM WITH TEST AFTER UNTIL COUNTER = 600000
  23.                ADD 1 TO COUNTER
  24.                MOVE SPACES TO MEMORY-LEAK
  25.                CALL 'CBL_OC_TIME' USING BY CONTENT START-TIME
  26.                CALL 'CBL_OC_TIME' USING BY CONTENT END-TIME
  27.                COMPUTE TIME-ELAPSED = END-TIME - START-TIME
  28.                IF TIME-ELAPSED < 600
  29.                    CONTINUE
  30.                ELSE
  31.                    EXIT PERFORM
  32.            END-PERFORM
  33.  
  34.            ADD NUM1 TO NUM2 GIVING RESULT
  35.            DISPLAY "FINALLY, THE RESULT IS: " RESULT
  36.  
  37.            STOP RUN.
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement