Write a C++ program to determine whether the year is a leap year or not.
Program Code:
#include<iostream>
using namespace std;
int main()
{
int year;
cout<<"Enter the year to be checked leap year or not : ";
cin>>year;
cout<<endl;
// Condition to check leap year or not
if( (year%400==0 || year%100!=0) && (year%4==0))
{
cout<<"Entered number is a leap year : ";
cout<<year;
}
else
{
cout<<"Entered number is not a leap year : ";
cout<<year;
}
return 0;
}
The program output is tested on www.jdoodle.com
Output:
Enter the year to be checked leap year or not : 2001
Entered number is not a leap year : 2001
Thanks
Mukesh Rajput
Post A Comment:
0 comments: