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
thanks dude you are great this code helped me in my project
i must tell you that there is a bug
#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”);
}