BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

C Program to check Leap Year

Last Updated: September 26, 2017 by Chaitanya Singh | Filed Under: C Programs

This program checks whether the input year is leap year or not.

Example: Program to check Leap Year

You can check whether a year is leap or not by using this mathematical logic:
Leap Year:
If a year is divisible by 4, 100 and 400 then it is a leap year.
If a year is divisible by 4 but not divisible by 100 then it is a leap year

Not a Leap Year:
If a year is not divisible by 4 then it is not a leap year
If a year is divisible by 4 and 100 but not divisible by 400 then it is not a leap year

Lets write this logic in a C Program. To understand this program you should have the knowledge of following C Programming topic:

  • C Programming If..else, Nested if..else
#include <stdio.h>
int main()
{
    int y;

    printf("Enter year: ");
    scanf("%d",&y);

    if(y % 4 == 0)
    {
    	//Nested if else
        if( y % 100 == 0)
        {
            if ( y % 400 == 0)
                printf("%d is a Leap Year", y);
            else
                printf("%d is not a Leap Year", y);
        }
        else
            printf("%d is a Leap Year", y );
    }
    else
        printf("%d is not a Leap Year", y);

    return 0;
}

Output:

Enter year: 1991
1991 is not a Leap Year

Check out these related C Programs:

  1. C Program to check whether an alphabet is vowel or consonant
  2. C Program to check if a number is palindrome or not
  3. C Program to check Armstrong number
  4. C Program to check if number is even or odd
  5. C Program to check if number is positive or negative

Top Related Articles:

  1. C Program to Convert time from 24 hour to 12 hour format
  2. C Program to print current date and time
  3. C Program to concatenate two strings without using strcat
  4. C Program to print date of birth using structure
  5. C program to calculate and print the value of nPr

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2012 – 2025 BeginnersBook . Privacy Policy . Sitemap