/* File leap4.cpp J. Shinnerl, 10/18/99 Version 4 uses a boolean function. Receives a year from the user and says whether the year is a leap year. By definition, a leap year is any year divisible by 4 except for years that are divisible by 100 but not divisible by 400. */ #include using namespace std; inline bool isLeapYear(int y) { return !( y%4 || !(y%100) && y%400 ); } int main() { cout << "\nEnter the year: "; int year; cin >> year; if (isLeapYear( year )) cout << year << " is a leap year.\n"; else cout << year << " is not a leap year.\n"; cout << endl; return 0; } /* SAMPLE I/0: barcarolle.cs.ucla.edu.24> a.out Enter the year: 1991 1991 is not a leap year. barcarolle.cs.ucla.edu.25> a.out Enter the year: 1992 1992 is a leap year. barcarolle.cs.ucla.edu.26> a.out Enter the year: 1994 1994 is not a leap year. barcarolle.cs.ucla.edu.27> a.out Enter the year: 1990 1990 is not a leap year. barcarolle.cs.ucla.edu.28> a.out Enter the year: 1900 1900 is not a leap year. barcarolle.cs.ucla.edu.29> a.out Enter the year: 2000 2000 is a leap year. barcarolle.cs.ucla.edu.30> */