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 :