Monday, February 5, 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);
}

0 comments:

Post a Comment