C++ code to find whether a given year is leap year or not

This program will tell you whether a given year is a leap year or not.

#include
#include
void main()
{
int n;
clrscr();
cout<<"Enter a year:";
cin>>n;
if(n%400==0)

cout<<"nNot a leap year."; else if(n%100==0) cout<<"nNot a leap year."; else if(n%4==0) cout<<"nIt's a leap year."; else cout<<"It's not a leap year."; getch();
}

Output:
Enter a year:2012
It’s a leap year.

Add Comment