46 C Program to Find if a given Year is a Leap Year
Posted by Superadmin on December 24 2015 02:10:31
This C Program checks whether a given year is a leap year. When A year is divided by 4. If remainder becomes 0 then the year is called a leap year.
Here is source code of the C program to check a given year is leap year. The C program is successfully compiled and run on a Linux system. The program output is also shown below.

/*
* C program to find whether a given year is leap year or not
*/
void main()
{
int year;

printf("Enter a year \n");
scanf("%d", &year);
if ((year % 400) == 0)
printf("%d is a leap year \n", year);
else if ((year % 100) == 0)
printf("%d is a not leap year \n", year);
else if ((year % 4) == 0)
printf("%d is a leap year \n", year);
else
printf("%d is not a leap year \n", year);
}

$ cc pgm47.c
$ a.out
Enter a year
2012
2012 is a leap year

$ a.out
Enter a year
2009
2009 is not a leap year