Thursday, April 7, 2011

Leap Year

A year is a leap year, if it is divisible by 4 but not by 100, except that years divisible by 400 are leap years.

if( ((year % 4 == 0)&&(year % 100 != 0)) || (year % 400 == 0) )
printf("%d is a leap year\n",year);
else
printf("%d is not a leap year\n",year);


REF: C Programming Language
Brian W. Kernighan &
Dennis M. Ritchie

No comments: