Stuck? Need help? Ask questions on our forums.

View \ZELLER.PAS

FACILIS is a p-code compiler for an extended subset of Pascal.

Submitted By: WEBMASTER
Rating: (Not rated) (Rate It)


program zeller(input, output);
{$t+ }
var     day, month, year,
        zday, m, y1, y2 : integer;

begin
   writeln('This program computes the day of the Week from the Date');
   writeln;
   write('Enter month:');
   read(month);
   writeln;
   write('Enter day:');
   read(day);
   writeln;
   write('Enter year:');
   read(year);
   if month < 3
   then begin
      m:=month + 10;
      year:=year - 1
   end else
      m:=month - 2;

   y1:=year div 100;
   y2:=year mod 100;

   zday:=(day + trunc(2.6*m - 0.1)
              + y2 + y2 div 4
                   + y1 div 4 - 2*y1 + 49) mod 7;

   writeln;
   write('Day of the week (0=Sun, 6=Sat):',zday)
end.

 4
                   + y1 div 4 - 2*y1 + 49) mod 7;

   writeln;

corner
© 1996-2008. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Publisher: Lars Hagelin.
bootstrapLabs Logo A bootstrapLabs project.