## Question Reference

C Home

### C Inbuilt Functions

C String FunctionsC Math Functions

### C Interview Programs

C Common ProgramsC Array ProgramsC Converter ProgramsC Star Patterns ProgramC Number Patterns ProgramC Alphabet Patterns Program

ASCII Table

# C Program to Check Leap Year

Last Updated:

## What is Leap Year?

A leap year is a calendar year containing one additional day added to keep the calendar year synchronized with the astronomical or seasonal year. For example, 2024 is a leap year.

Tips: It is recommended to use our online Leap Year calculator for better understanding.

## Condition for Leap Year

To check whether a year is a leap year or not, the year should satisfy at least one of the following two conditions

1. A year should be exactly divisible by 4, but, not by 100.
2. A year should be exactly divisible by 4, 100 and 400 at the same time.

## Check Leap Year

In the following example, we will check whether the given year (2012) is leap year or not.

### Example

C Compiler
#include <stdio.h> int main() { int year = 2012; if(year % 4 == 0) { if((year % 100 == 0) && (year % 400 != 0)) printf("%d is not a leap year", year); else printf("%d is a leap year", year); } else printf("%d is not a leap year", year); return 0; }

## Leap Years between the Given Range

In the following example, we will find all the Leap Years between 2000 and 2030.

### Example

C Compiler
#include <stdio.h> int main() { int start = 2000; int end = 2030; printf("Leap years between %d and %d:\n", start, end); for(start=start; start<=end; start++) { if(start % 4 == 0) { if((start % 100 == 0) && (start % 400 != 0)) { // Not a leap year } else printf("%d ", start); } } return 0; }

## Check Leap Year for any Given Year

In the following example, we will check whether the given year is a leap year or not.

### Example

C Compiler
#include <stdio.h> int main() { int year; printf("Enter a year: "); scanf("%d", &year); if(year % 4 == 0) { if((year % 100 == 0) && (year % 400 != 0)) printf("%d is not a leap year", year); else printf("%d is a leap year", year); } else printf("%d is not a leap year", year); return 0; }