C++ Program to Check Whether a Year is Leap Year or not

In this program, you'll learn to check given year is Leap Year or not.

A year is leap if it divisible by 4. A year is a leap year if it satisfy following conditions:

1) It is evenly divisible by 100
2) If it is divisible by 100, then it should also be divisible by 400
3) Except this, all other years evenly divisible by 4 are leap years.



Source Code
#include<iostream>
using namespace std;

int main()
{
    int year;
    cout<<"Enter the year: ";
    cin>>year;

    if(((year % 4 == 0) && (year % 100!= 0)) || (year%400 == 0))
    {
        cout<<"Leap year";
    }
    else
    {
        cout<<"Not a Leap year";
    }
    return 0;
}
Output
Enter the year: 2016
Leap year

Enter the year: 2050
Not a Leap year