Task

Determine whether a given year is a leap year in the Gregorian calendar.



See also

 Leap year (wiki)


BYTE FUNC IsLeapYear(CARD year)
  IF year MOD 100=0 THEN
    IF year MOD 400=0 THEN
      RETURN (1)
    ELSE
      RETURN (0)
    FI
  FI
 
  IF year MOD 4=0 THEN
    RETURN (1)
  FI
RETURN (0)
 
PROC Main()
  CARD ARRAY t=[1900 1901 2000 2001 2004 2020 2021]
  BYTE i,leap
  CARD year
 
  FOR i=0 TO 6
  DO 
    year=t(i)
    leap=IsLeapYear(year)
    IF leap=0 THEN
      PrintF("%U is not a leap year%E",year)
    ELSE
      PrintF("%U is a leap year%E",year)
    FI
  OD
RETURN