A leap year is a calendar year containing one additional day added to keep the calendar year synchronized with the astronomical or seasonal year.
Leap year has 366 days in a year(February month with 29 days).
Non-leap year has 365 days in a year.
//Write a C program to check leap year.
#include <stdio.h>
int main ()
{
int year;
printf("Enter Year to check:");
scanf("%d",&year);
if(year%400 == 0 || (year%100 != 0 && year%4 == 0)){
printf("%d is leap year.",year);
}
else{
printf("%d is not leap year.",year);
}
return 0;
}
Output 1:
Enter Year to check:2016
2016 is leap year.
Output 2:
Enter Year to check:2017
2016 is not leap year.
Leap year has 366 days in a year(February month with 29 days).
Non-leap year has 365 days in a year.
#include <stdio.h>
int main ()
{
int year;
printf("Enter Year to check:");
scanf("%d",&year);
if(year%400 == 0 || (year%100 != 0 && year%4 == 0)){
printf("%d is leap year.",year);
}
else{
printf("%d is not leap year.",year);
}
return 0;
}
Output 1:
Enter Year to check:2016
2016 is leap year.
Output 2:
Enter Year to check:2017
2016 is not leap year.
No comments:
Post a Comment