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
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: