SOURCE FILE: EX0408.CPP
// Example 4.8. Program to test for leap year
/*
Notice here that the logic of the condition in the if-test can be intricate.
The rules of C++ allow us to state very complex conditions.
*/
#include <iostream>
using namespace std ;
int main(void)
{
int year; // year to test
cout << "Please enter a year: ";
cin >> year;
//
// if year is divisible by 4 AND not divisible by 100
// OR is divisible by 400, then it is a leap year
//
if ( ((year % 4 == 0) && (year % 100 != 0))
|| (year % 400 == 0))
cout << "" << year << " is a leap year.\n";
else
cout << "" << year << " is not a leap year.\n";
return 0;
}