C Program To Check Leap Year
Learn How To Check Leap Year in C Programming Language. We have listed a well-researched Algorithm and Logic below for this program. To understand this program code efficiently, you must know How A Modulus Operator Works in C Programming Language. This code finds if a year entered by the User is a Leap Year or not using If Else Block Structure.
What is a Leap Year?
A Regular Year consists of 365 days. However, a Leap one consists of 366 days. It occurs after every three years and every fourth consecutive year is Leap. It consists of 52.2857 Weeks. This Leap Year C Program is based on the Gregorian Calendar.
Example
2004, 2008, 2012, 2016
Also Read: C Program To Delete Vowels From A String
C Program To Check Leap Year using If Else
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | #include<stdio.h> int main() { int l_year; printf("\nEnter a Year:\t"); scanf("%d", &l_year); if(l_year%400 == 0) { printf("\n%d is a Leap-Year\n", l_year); } else if(l_year%4 == 0) { if(l_year%100 == 0) { printf("\n%d is not Leap\n", l_year); } else { printf("\n%d is a Leap-Year\n", l_year); } } else { printf("\n%d is not Leap\n", l_year); } return 0; } |
C Program To Find Leap Years from 1 To N
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #include<stdio.h> int main() { int year, limit, count; printf("Enter The Starting Year:\t"); scanf("%d", &year); printf("Enter The Ending Year:\t"); scanf("%d", &limit); do { if(year % 400 == 0) { printf("\n%d is a Leap Year\n", year); year++; } else if(year%4 == 0) { if(year%100 == 0) { printf("\n%d is not Leap\n", year); year++; } else { printf("\n%d is a Leap-Year\n", year); year++; } } else { printf("\n%d is not a Leap Year\n", year); year++; } }while(year <= limit); return 0; } |
Output

Also Read: C Program To Print Map of India
In case you get any Compilation Errors with this Code To Check Leap Year in C Programming Language or you have any doubt about it, let us know about it in the Comment Section below.
Finally I got this code! This is just so easy to understand with all the conditions in different If Else blocks. Thank you so much!
I am glad that you found this code interesting and easy!
I was wondering if it is possible to find the date of the leap year in this C Program?
Yes. You can definitely find the leap year date in this C Code. However, that might make the code more complex, but its not that difficult. You need to find in a Library function that checks the date. There are some library functions available under the header .
This the most self explanatory code for leap year in C programming. I find it really easy to understand. Thanka for clearing my concepts about leap year.
The If-Else structure has helped a lot to understand the logic behind a C program to find if the year is a leap year or not. Thanks.