C++ Program to Check Leap Year

Here is C++ program to check whether a year is a leap year or not.

A leap year consists of 366 days instead of 365 days. In a leap year, February month consists of 29 days.

#include<iostream>

using namespace std;

int main()
{
    int year;
    cout<<"Enter Year(ex:1900):";
    cin>>year;
    
    if(year%100==0)
    {
        if(year%400==0)
        cout<<"\nLeap Year";
    }
    else
        if(year%4==0)
            cout<<"\nLeap Year";
        else
            cout<<"\nNot a Leap Year";
    
    return 0;
}

Output:

Enter Year(ex:1900):2000
Leap Year

3 thoughts on “C++ Program to Check Leap Year”

  1. #include
    main()
    {
    int a;
    printf(“Enter a year”);
    scanf(“%d”,&a);
    if(a%4==0)
    printf(“Year is a leap year”);
    else
    printf(“Year is not a leap year”);
    }

Leave a Comment

Your email address will not be published. Required fields are marked *