Saturday, 1 March 2014

COBOL Program to implement PERFORM UNTIL verb



COBOL Program to implement PERFORM UNTIL verb

PROGRAM:  

       IDENTIFICATION DIVISION.
       PROGRAM-ID PRFUN.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 N PIC 9(2) VALUE 0.
       01 I PIC 9(2) VALUE 1.
       01 SUM PIC 9(4) VALUE 0.
       PROCEDURE DIVISION.
       PARA1.
           DISPLAY ( 1 1 ) ERASE.
           DISPLAY ( 5 5 ) "ENTER A NUMBER".
           ACCEPT N.
           PERFORM CALA-PARA UNTIL I > N.
           DISPLAY ( 10 5 ) "SUM = " SUM.
           STOP RUN.
       CALA-PARA.
           COMPUTE SUM = SUM + I.
           ADD 1 TO I.

No comments: