PROGRAM-ID. FIBONACCI.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 A PIC S99 VALUE -1.
77 B PIC 99 VALUE 1.
77 C PIC 99.
77 N PIC 99.
77 N1 PIC 99 VALUE 0.
PROCEDURE DIVISION.
PARA1.
DISPLAY "ENTER A NUMBER".
ACCEPT N.
PERFORM PARA2 UNTIL N1 = N.
STOP RUN.
PARA2.
COMPUTE C = A + B;
DISPLAY C.
MOVE B TO A.
MOVE C TO B.
ADD 1 TO N1.
No comments:
Post a Comment