Can anyone tell me whay the following funtion that should be returning true if the year is leap year and false if it is not, is givign me unexpected results? when I entered 1985 I got true? when I entered 2012 I got false. When I entered 2000 I got true, it was actually right on that one. I'M building a program that will validate if a date is valid or not based on the number of days in each month, I need leap year to determin the max days in FEB, etc... I frist wrote the program in bash and it worked just fine. Now that I've converted the formula over to C++ it's not working out.
bool is_leap_year( int year )
{
bool result = false;
int local_year = year;
if ( 0 == (( local_year % 4 ) && 0 != ( local_year % 100 )) || 0 != ( local_year % 400 ) )
{
result = true;
}
return result;
}
/*END*/