COBOL Program to implement
Factorial of a Given Number
PROGR AM:
IDENTIFICATION
DIVISION.
PROGRAM-ID FACT.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 I PIC 9(8).
77 F PIC 9(8) VALUE 1.
77 N PIC 9(8).
77 P PIC 9(8).
PROCEDURE DIVISION.
MAIN-PARA.
DISPLAY "ENTER ANY
NUMBER".
ACCEPT N.
PERFORM X-PARA VARYING I FROM 1 BY 1
UNTIL I > N.
MOVE F TO P.
DISPLAY "FACTORIAL OF GIVEN
NUMBER IS" P.
STOP RUN.
X-PARA.
COMPUTE F = F * I.
No comments:
Post a Comment