Check whether year is a leap year or not

Description:

Any year is input by the user. Write a program to determine whether the year is a leap year or not. Test Case 1 Input (stdin) 2016 Expected Output It is a leap year Test Case 2 Input (stdin) 2017 Expected Output It is not a leap year

Program :


#include <iostream>

using namespace std;

int main()

{

int yr;

cin>>yr;

if((yr%4==0) && (yr%100!=0))

{

cout<<"It is a leap year";

}

else if((yr%100==0) && (yr%400==0))

{

cout<<"It is a leap year";

}

else if(yr%400==0)

{

cout<<"It is a leap year";

}

else

{

cout<<"It is not a leap year";

}}