Problem Description
Lucy is celebrating her 15th birthday. Her father promised her that he will buy her a new computer on her birthday if she solves the question asked by him. He asks Lucy to find whether the year on which she had born is leap year or not. Help her to solve this puzzle so that she celebrates her birthday happily. If her birth year is 2016 and it is a leap year display 2016 is a leap year.? Else display 2016 is not a leap year and check with other leap year conditions.Test Case 1
Input (stdin)1900
Expected Output1900 is not a leap year
Test Case 2
Input (stdin)2016
Expected Output2016 is a leap year
Program
#include <stdio.h> int main() { int a; scanf("%d",&a); if(a%400==0) { printf("%d is a leap year",a); } else if(a%100==0) { printf("%d is not a leap year",a); } else if(a%4==0) { printf("%d is a leap year",a); } else printf("%d is not a leap year",a); return 0; }
No comments:
Post a Comment
Note: only a member of this blog may post a comment.