Monday, 5 February 2007

Boolean Expression to Determine if a Year is Leap

The following is a C function that determines if a year is leap. Comes in pretty handy and is easy to convert to other languages as well.
    int isLeap[int year)
    {
       return (year % 4 == 0) && (year % 100 != 0 || year % 400 == 0);
    }

No comments:

Post a Comment

I have had so many good people trying to promote various community oriented sites through here. Therefore all comments will first have to come through me... so I get a chance to learn about the interesting sites before you do ...