C Program to check whether the year is a leap year or not?

C Program to check whether the year is a leap year or not?

You must have heard the name of Leap Year and be aware of what it is, but many people do not have the right information about it and remain confused.

So for your information, let me tell you that Leap Year is a year in which there are 366 days, and this happens when February 29 comes.

It comes once in every four years. In simple language, the year that is completely divided by 4 or 400 but not completely divided by 100 is called the leap year.

This happened about leap year, but do you know how to write a program through which you can ask your computer which year is Leap Year and which is not?

If you do not know, then stay with us because in this post we have told you how to write the code to know Leap Year in C.

C Program to check whether the year is a leap year or not

/*C Program to check whether the year is a leap year or not?*/
#include <stdio.h>

int main()
{
    int year;

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

    if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
    {
        printf("%d is a leap year.\n", year);
    }
    else
    {
        printf("%d is not a leap year.\n", year);
    }

    return 0;
}

Summary

If you want to learn similar programming questions and concepts in an easy language, then you can explore our site, where you will find a lot of content.

Similar articles

About The Author

Leave a reply

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