C Leap Year

Program

Program

C Program for leap year is easy to learn and quick. By using simple codes you can check whether the given year is leap year or not.

Here on our page, we provide you easy example to find a leap year by using C language.

Here on our page, we provide you easy example to find a leap year by using C language.

The program takes the input of the year and gives the output whether the input year is a leap year or not.

Problem Solution

1. Take a year as input.

2. Check whether a given year is divisible by 400.

3. Check whether a given year is divisible by 100.

4. Check whether a given year is divisible by 4.

5. If the condition at step 2 and 4 becomes true, then the year is a leap year.

6. If the condition at step 3 becomes true, then the year is not a leap year.

` ````
/*
* 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);
}
```

` ````
Enter a year
2012
2012 is a leap year
Enter a year
2009
2009 is not a leap year
```