# Leap year program in C

Problem Statement: Check if the given year is a leap year or not. Leap year program in C.

Examples:

```Example 1:
Input: 1996
Output: Yes
Explanation: 1996 is a leap year

Example 2:
Input: 2000
output: Yes
Explanation: 2000 is a leap year```

DisclaimerDon’t jump directly to the solution, try it out yourself first.

## What is Leap Year?

A leap year is an year, occurring once every four years, which has 366 days including 29 February as an intercalary day.

Approach:

A year is a leap year if:

• either, it is divisible by 400
• or, divisible by 4 and not divisible by 100.

So we check if the given year is

• divisible by 400 or,
• divisible 4 and not divisible by 100

Code:

## C Program

``````#include<stdio.h>
int yyear(int year)
{
if(year % 400 == 0)
return 1;
if(year % 100 == 0)
return 0;
if(year % 4 == 0)
return 1;
return 0;
}
int main()
{
int year=1996;
if(yyear(year))
printf("Yes, it is a leap year");
else
printf("No, it is not a leap year");
}``````

Output: Yes, it is a leap year

Time Complexity: O(1)

Space Complexity: O(1)