L. LeapYear
Problem linkhttps://algo.codemarshal.org/contests/diu-122-fl16-termwork/problems/L
Score: 1
CPU: 1s
Memory: 512MB
CPU: 1s
Memory: 512MB
In general terms, a leap year is a year that is divisible by 4. However, if a year is divisible by 100, that is not a leap year. But there is another catch, if the year is divisible by 400, then it's a leap year.
Input
A single integer denoting the year.
Output
If the input is a leap year print YES. Else print NO
Samples
Input | Output |
---|---|
2015 | NO |
Input | Output |
---|---|
2204 | YES |
Solution
#include<stdio.h> int main() { int year; scanf("%d",&year); if((year%4==0 && year%100!=0)|| year%400==0){ printf("YES\n"); } else{ printf("NO\n"); } return 0; }
No comments:
Post a Comment