C++ Program to Check Leap Year

C++ Program to Check Leap Year

How can we check Leap Year in C++? Leap year is that year which has 366 days, and the extra day is in the month of February (29th)

Leap year in C++ :



#include <iostream>
using namespace std;

int main() 
{
    int year;
    cout << "Please Enter the Year you wish : ";
    cin >> year;

    if (year%400 == 0)
        cout << year << " is a Leap Year";
    else if (year%100 == 0)
        cout << year << " is a Leap Year";
    else if (year%4 == 0)
        cout << year << " is a Leap Year";
    else
        cout << year << " is NOT a Leap Year";

    return 0;
}
         

Output :