# Leap Year Program & Algorithm in C Programming Language

C programming is powerful to find out various things using some powerful codes. Users can make use of it to write a program to check leap year in C. Finding that whether a year is a leap or not can be a bit tricky, but here we are going to write a leap year program in C to help you get at ease.

Generally, we assume that if any year number that we take is evenly divisible by 4 is considered a leap year, you cannot rely on that. There are few conditions for a leap year.

Table of Contents

### Leap Year:

In case the year number is divisible by 4, or you can say 100 and 400, then we can assume that it is a leap year.

To write a program to check the leap year in c, If the year number is divisible by 4 but not divisible by 100, then we can say that it is a leap year.

### Not a Leap Year:

If that year’s number is not divisible by the value of 4, it is not considered a leap year.

If the same year number is divisible by 4 and 100, but it may not be divisible by 400, then we can say that it is not a leap year.

We can write a program to find leap year in C to help you understand better about Leap year and its C program. Here is the example.

## Program to find leap year in C

Following is the program for leap year in c.

#include <stdio.h> int main() { int year; printf("Enter year: "); scanf("%d", &year); // leap year if divisible by 400 if (year % 400 == 0) { printf("%d is a leap year.", year); } // not a leap year if it is divisible by 100 // but not divisible by 400 else if (year % 100 == 0) { printf("%d is not a leap year.", year); } // leap year if not divisible by 100 // but divisible by 4 else if (year % 4 == 0) { printf("%d is a leap year.", year); } // all other years are not leap years else { printf("%d is not a leap year.", year); } return 0; }

#### Output 1

Enter year: 1700 1700 is not a leap year.

#### Output 2

Enter a year: 2016 2016 is a leap year.

## Leap Year Algorithm

Algorithm of the program for leap year in C

Start

- Take int variable year
- Assign the value to that variable
- Check if the taken year is divisible by 4 but not 100, then DISPLAY “leap year.”
- Check if that year number is divisible by 400, then DISPLAY “leap year.”
- Else, DISPLAY “not leap year.”

Stop

Also Read: Merge Sort Algorithm in C

## Conclusion

This was a discussion on the leap year program in C with an example and algorithm. For more info, leave a reply in the box given below.

## FAQ’s

### How do you write a program for a leap year?

Leap Year Program in C can be written as.

- It is divisible by 100. In case it is divisible by 100, it should also be divisible by 400.
- Except for this condition, all of the other years that are divisible by 4 are leap years.