Created
June 8, 2018 22:04
-
-
Save asierba/58224460a5c4d5b787909b9844078eb2 to your computer and use it in GitHub Desktop.
Fizzbuz 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
PROGRAM-ID. FIZZBUZZ. | |
DATA DIVISION. | |
WORKING-STORAGE SECTION. | |
01 BY-3 PIC 9(1). | |
01 BY-5 PIC 9(1). | |
01 C PIC 9(2). | |
01 I PIC 9(3) VALUE 1. | |
PROCEDURE DIVISION. | |
PERFORM FIZZBUZZ-OF VARYING I FROM 1 BY 1 UNTIL I=100 | |
STOP RUN. | |
FIZZBUZZ-OF. | |
DIVIDE I BY 3 GIVING C REMAINDER BY-3 | |
DIVIDE I BY 5 GIVING C REMAINDER BY-5 | |
EVALUATE TRUE | |
WHEN BY-3 = 0 AND BY-5 = 0 | |
DISPLAY 'FIZZBUZZ' | |
WHEN BY-3 = 0 | |
DISPLAY 'FIZZ' | |
WHEN BY-5 = 0 | |
DISPLAY 'BUZZ' | |
WHEN OTHER | |
DISPLAY I | |
. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment