SOURCE FILE: EX0408.CPP


// Example 4.8.  Program to test for leap year 
   
#include <iostream.h>
   
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;
}