# C++ program to check leap year

Given a year, we have to check whether it is a leap year or not using C++ program.
[Last updated : February 27, 2023]

## Problem statement

In this program, we will learn how to check Leap year? Here we are taking year from the user and checking whether input year is Leap year or not.

## Logic for checking leap year in C++

A year is Leap year, if it satisfies two conditions:

1. Year is divisible by 400 (for century years)
2. Year is divisible by 4 and not divisible by 100 (for non century years)

## C++ program to check leap year

```#include <iostream>
using namespace std;

int main()
{
int 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
```