LUCY
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.
CODING ARENA
#include <stdio.h>
int main()
{
int year;
scanf("%d",&year);
if(year%400==0)
{
printf("%d is a leap year",year);
}
else if(year%100==0)
{
printf("%d is not a leap year",year);
}
else if(year%4==0)
{
printf("%d is a leap year",year);
}
else
{
printf("%d is not a leap year",year);
}
return 0;
}
Test Case 1
Input (stdin)1900
Expected Output
1900 is not a leap year
Test Case 2
Input (stdin)2016
Expected Output
2016 is a leap year
No comments:
Post a Comment