C Program to Check Leap Year

You might be familiar with Leap year, which comes in around every four years, like for example, 2024, 2028, 2032, 2036, and more, are leap years. Well, any other year has 365 days, but the leap year has 366 days (29 February).

C Program to Check Leap Year

If you need to calculate whether the given year is a leap year, you can write a C program for that. So, in this article, we are going to learn about a simple C program, using which, you can find whether or not the given year is a leap year. Through the given video, you can find the detailed explanation and program for checking if the given year is a leap or not.

Here is the C program to check if the given year is a leap year or not.

#include <stdio.h>

int main() {
int year;

// Asking for the year as User input
printf(“Enter a year: “);
scanf(“%d”, &year);

// Checking if the year is leap or not
if (year % 400 == 0) {
printf(“%d – leap year.n”, year);
} else if (year % 100 == 0) {
printf(“%d – not a leap year.n”, year);
} else if (year % 4 == 0) {
printf(“%d – leap year.n”, year);
} else {
printf(“%d – not a leap year.n”, year);
}
return 0;
}

Program Output Case 1 –
Enter a year: 2024
2024 – leap year.

Program Output Case 2 –
Enter a year: 2025
2025 – not a leap year.