Leap Year Checker...even more to it

Evan Marshall Manning manning at nntp-server.caltech.edu
Mon Oct 1 08:13:35 AEST 1990


cak3g at astsun9.astro.Virginia.EDU (Colin Klipsch) writes:

>int is_leap_year(int year)
>{
>   if (year%4000 == 0) return FALSE;
>   else if (year%400 == 0) return TRUE;
>   else if (year%100 == 0) return FALSE;
>   else if (year%4 == 0) return TRUE;
>   else return FALSE;
>}

All other things being equal, I've got to vote for the versions that make
the tests most likely to be decisive first.  Years like 1990 will have
to undergo all of the tests above.

***************************************************************************
Your eyes are weary from staring at the CRT for so | Evan M. Manning
long.  You feel sleepy.  Notice how restful it is  |      is
to watch the cursor blink.  Close your eyes.  The  |manning at gap.cco.caltech.edu
opinions stated above are yours.  You cannot       | manning at mars.jpl.nasa.gov
imagine why you ever felt otherwise.               | gleeper at tybalt.caltech.edu



More information about the Comp.lang.c mailing list