# Check Leap Year

Check Leap Year” is a basic programming exercise problem. Here, we are given a year, entered by user and our task is to check whether an entered year is a leap year or not.

Condition to Check leap year:

1. The primary condition for leap year is that it is divisible by 4.
2. If the entered year is century year (i.e., 100,200,300 etc.), then it must be divisible by 400. Else, it will not be a leap year.

#### Example (Check Leap Year):

```INPUT:
Year = 2000
OUTPUT:
Leap Year
INPUT:
Year = 2019
OUTPUT:
Not Leap Year```

C++ Program to check whether a year is leap year or not is as follows:

```/* C++ Program to check leap year */
#include<bits/stdc++.h>
using namespace std;
int main()
{
int year;
//Scan the year
cout<<"Enter the year:";
cin>>year;

// Primary condition : Year must be divisible by 4
if(year % 4 == 0)
{
// Condition for century Year
if(year %100 == 0)
{
// Century Year must be divisible by 400
if(year % 400 == 0)
{
cout<<"Leap Year";
}
else
{
cout<<"Not Leap Year";
}
}
else
{
cout<<"Leap Year";
}
}
else
{
cout<<"Not Leap Year";
}
}
```
```OUTPUT:
Enter the year: 2000
Leap Year```

Related Posts: