Leap year

A leap year is a calendar year that includes an additional day to synchronize the calendar year with the astronomical or seasonal year. – Wikipedia

Logic

The Logic to check this is quite simple. We only need to check if the given year is multiple of 4 or 400, but it should not be multiple of 100.

Program

#include <iostream>

using namespace std;

int main() {

    int year;

    cout << "Enter a year : ";
    cin >> year;

    if (year % 4 == 0) {

        if (year % 100 == 0) {

            if (year % 400 == 0) {
                cout << endl << year << " is a leap year.";
            } else {
                cout << endl << year << " is not a leap year.";
            }
                
        } else {
            cout << endl << year << " is a leap year.";
        }

    } else {
        cout << endl << year << " is not a leap year.";
    }

    return 0;
}

Output

Enter a year : 2012
2012 is a leap year.