#include <iostream>
using namespace std;
int main()
{
int year;
//read year
cout<<"Enter a year: ";
cin>>year;
if((year%400==0)||(year%4==0 && year%100!=0))
cout<<year<<" is Leap year"<<endl;
else
cout<<year<<" is not Leap year"<<endl;
return 0;
}
Output
First run:
Enter a year: 2000
2000 is Leap year
Second run:
Enter a year: 2005
2005 is not Leap year
Third run:
Enter a year: 1900
1900 is not Leap year
Fourth run:
Enter a year: 1904
1904 is Leap year
Program to check Leap year or not in C++
Output
need an explanation for this answer? contact us directly to get an explanation for this answer