Q. Accept any year as input through the keyboard. Write a program to check whether the year is a leap year or not.
Program
#include <stdio.h>
int main()
{
int year;
printf("enter year : ");
scanf("%d",&year);
if (((year % 4 == 0) && (year % 100!= 0)) || (year%400 == 0))
{
printf("%d is a leap year", year);
}
else
{
printf("%d is not a leap year", year);
}
}
Output:
enter year : 2000
2000 is a leap year
Program
#include <stdio.h>
int main()
{
int year;
printf("enter year : ");
scanf("%d",&year);
if (((year % 4 == 0) && (year % 100!= 0)) || (year%400 == 0))
{
printf("%d is a leap year", year);
}
else
{
printf("%d is not a leap year", year);
}
}
Output:
enter year : 2000
2000 is a leap year
0 Comments