TechoSagar: Leap Year

Search

Google Alert - jobs

Leap Year

For an input year tell whether the year is leap or not. 
Input:
First line contains an integer, the number of test cases 'T' Each test case should contain a positive integer N(Year).

Output:
Print "Yes" if it is a leap year else "No". (Without the double quotes)

Constraints:
1<=T<=31
1<=N<=9999

Example:
Input:
1
4
Output:
Yes
Your Code
#include<iostream>

using namespace std;

int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
if(n%4==0 && n%100!=0)
cout<<"Yes"<<endl;
else if(n%400==0)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
return 0;

}

Follow us

Follow Bijendra Kumar on Facebook