Leap Year Checker.

Dave Gaulden cze2529 at dcsc.dla.mil
Sat Sep 29 01:47:15 AEST 1990


In article <24700010 at sunc1> mccaugh at sunc1.cs.uiuc.edu writes:
>
> Ordinarily, a leap-year is a multiple of four, so thst -- given leap-year y --
> (y%4 == 0) ought to indicate if y designates a leap-year.

In article <9464 at uhccux.uhcc.Hawaii.Edu> bush at uhccux.uhcc.Hawaii.Edu (Anthony Bush) writes:
>date in 1945 so and so happened.. The trouble I am having is figuring
>out the code in C++ in which it can figure out if the current year
>is a leap year or not. Any help is appreciated.

The following is a standard leapyear algorithm function if it is 
any help.

main()
{
 blah...blah....

 if (month > 2)
     days += leapyear(year);

}

int leapyear(int year)      /* standard leapyear algorithm */
{
   if (year % 4 == 0 && year % 100 != 0 !! year % 400 == 0)
       return 1;
   else
       return 0;
}

Uses the return value to add the day if true.
-- 

"Man who says, 'It cannot be done', should not interrupt man who is doing it."

 Dave Gaulden cze2529 at dcsc.dla.mil



More information about the Comp.lang.c mailing list