IDENTIFICATION DIVISION.
PROGRAM-ID. program.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 example.
02 year PIC 9(4).
02 FILLER PIC X VALUE " ".
02 result PIC X.
PROCEDURE DIVISION.
MOVE 1000 TO year
CALL "is-leap-year" USING year, result
DISPLAY example
MOVE 2000 TO year
CALL "is-leap-year" USING year, result
DISPLAY example
MOVE 2004 TO year
CALL "is-leap-year" USING year, result
DISPLAY example
MOVE 2016 TO year
CALL "is-leap-year" USING year, result
DISPLAY example
MOVE 2017 TO year
CALL "is-leap-year" USING year, result
DISPLAY example
STOP RUN
.
END PROGRAM program.
IDENTIFICATION DIVISION.
PROGRAM-ID. is-leap-year.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 by-4 PIC 9(4) COMP.
01 by-100 PIC 9(4) COMP.
01 by-400 PIC 9(4) COMP.
LINKAGE SECTION.
01 year PIC 9(4).
01 result PIC X.
PROCEDURE DIVISION USING year, result.
COMPUTE by-4 = FUNCTION mod(year, 4)
COMPUTE by-100 = FUNCTION mod(year, 100)
COMPUTE by-400 = FUNCTION mod(year, 400)
IF by-4 = 0 AND (by-100 <> 0 OR by-400 = 0) THEN
MOVE 'Y' TO result
ELSE
MOVE 'N' TO result
END-IF
EXIT PROGRAM
.
END PROGRAM is-leap-year.