Last active
April 22, 2021 01:26
-
-
Save YamadaKyohei/78e377ed65b514671445dcfaf3e07809 to your computer and use it in GitHub Desktop.
Fizz Buzz in COBOL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IDENTIFICATION DIVISION. | |
PROGRAM-ID. FIZZ-BUZZ. | |
DATA DIVISION. | |
WORKING-STORAGE SECTION. | |
01 X PIC 99. | |
01 DIV PIC 99. | |
01 REM-3 PIC 9. | |
01 REM-5 PIC 9. | |
PROCEDURE DIVISION. | |
MOVE 0 TO X. | |
PERFORM UNTIL X > 98 | |
ADD 1 TO X | |
DIVIDE X BY 3 GIVING DIV REMAINDER REM-3 | |
DIVIDE X BY 5 GIVING DIV REMAINDER REM-5 | |
IF REM-3 = 0 AND REM-5 = 0 THEN | |
DISPLAY "Fizz Buzz" | |
ELSE IF REM-3 = 0 THEN | |
DISPLAY "Fizz" | |
ELSE IF REM-5 = 0 THEN | |
DISPLAY "Buzz" | |
ELSE | |
DISPLAY X | |
END-IF | |
END-PERFORM. | |
STOP RUN. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment