Date Validation —
Is this a Leap Year?

```Hi There:

I say there was a February 29 in 1944.  A friend says it wasn't a leap year.

 ``` // DATEVAL.C // Author: Peter Meyer // Last modified: 1999-02-18 // Free to use. #define TRUE 1 #define FALSE 0 int is_leap_year(int year); /*-------------------------------------------*/ int date_is_valid(int day, int month, int year) { int valid = TRUE; int month_length = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; if ( is_leap_year(year) ) month_length = 29; // 29 days in February in a leap year (including year 2000) if ( month < 1 || month > 12 ) valid = FALSE; else if ( day < 1 || day > month_length[month] ) valid = FALSE; return ( valid ); } /*----------------------*/ int is_leap_year(int year) { int result; if ( (year%4) != 0 ) // or: if ( year%4 ) result = FALSE; // means: if year is not divisible by 4 else if ( (year%400) == 0 ) // or: if ( !(year%400) ) result = TRUE; // means: if year is divisible by 400 else if ( (year%100) == 0 ) // or: if ( !(year%100) ) result = FALSE; // means: if year is divisible by 100 else // (but not by 400, since that case result = TRUE; // considered already) return ( result ); } ```