Program Faktorial dalam COBOL

IDENTIFICATION DIVISION.
PROGRAM-ID.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 A PIC 9(2).
77 B PIC 9(8) VALUE 1.
77 C PIC 9(2).
77 D PIC Z(8).
PROCEDURE DIVISION.
MAIN-PARA.
                       DISPLAY ” ENTER ANY NUMBER “.
                       ACCEPT A.
                       PERFORM Faktorial VARYING C FROM 1 BY 1 UNTIL C > A
                       MOVE B TO D.
                      DISPLAY ” THE FACTORIAL OF THE GIVEN NUMBER IS ” D.
                      STOP RUN.
Faktorial.
                      COMPUTE B = B * C.

 

 

Source : http://easycode.kuguni.com/complete.php?id=321&meta=PROGRAM%20TO%20FIND%20THE%20FACTORIAL%20OF%20THE%20GIVEN%20NUMBER%20Using%20Cobol

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s