A Program to Test if a Year is a Leap Year

Here is the program to test if a year if a leap year. It differs from the one we saw in class in that it is no longer vague in its output about what the program does (since you all know what it does now).
program leapyear;

{
  This program determines whether a year (entered by
  the user) is a leap year.
}

var
  year : integer;

begin
  write('Enter a year: ');
  readln(year);

  if (year mod 4 = 0) and (year mod 100 <> 0) or
       (year mod 400 = 0) then
    writeln(year, ' is a leap year')
  else
    writeln(year, ' is NOT a leap year');
end.

After we compile the program into a executable named leapyear and then run the program, we get:

% leapyear
Enter a year: 1997
      1997 is NOT a leap year

% leapyear
Enter a year: 2000
      2000 is a leap year

CS101 - A Program to Test if a Year is a Leap Year / Robert I. Pitts / rip@cs.bu.edu