000001* プログラムの定義部分 --- (*1)
000002 IDENTIFICATION DIVISION.
000003 PROGRAM-ID.    FIZZ-BUZZ.
000004 DATA           DIVISION.
000005* 変数の定義 --- (*2)
000006 WORKING-STORAGE SECTION.
000007 01 CNT PIC 999 VALUE 0. 
000008 01 FIZZ PIC 99 VALUE 0.
000009 01 BUZZ PIC 99 VALUE 0.
000010* メインプログラム--- (*3)
000011 PROCEDURE DIVISION.
000012*    100回の繰り返し --- (*4)
000013     PERFORM 100 TIMES
000014         ADD 1 TO CNT
000015         COMPUTE FIZZ = FUNCTION MOD(CNT 3)
000016         COMPUTE BUZZ = FUNCTION MOD(CNT 5)
000017*        次々と分岐させる --- (*5)
000018         IF FIZZ = 0 AND BUZZ = 0 THEN
000019             DISPLAY "FizzBuzz"
000020         ELSE IF FIZZ = 0 THEN
000021             DISPLAY "Fizz"
000022         ELSE IF BUZZ = 0 THEN
000023             DISPLAY "Buzz"
000024         ELSE
000025             DISPLAY CNT
000026         END-IF
000027     END-PERFORM.
000028 STOP RUN.

