Skip to main content

C Program to check Leap Year

Programming Languages

Welcome to coding world

C Program to check Leap Year 

 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

Let’s 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

Popular posts from this blog

Explore the beauty of Murree | A memorable tour from Lahore to murree | Tour packing tips

Memorable Murree Getaway As we set off from Lahore, the excitement was palpable. The scenic drive to Murree was breathtaking, with lush green hills and winding roads. After a four-hour journey, we arrived in Murree, and the crisp mountain air invigorated us. We spent the day exploring Mall Road, browsing local shops, and savoring delicious food at restaurants. The stunning views of the hills and valleys left us spellbound. As the sun set, we settled into our cozy hotel, feeling grateful for this escape from the city's hustle. The next day, we visited the iconic Patriata Chair Lift (if operational) and took in the panoramic views. Our hotel's scenic location offered breathtaking sunrises and sunsets. As we reluctantly bid farewell to Murree and headed back to Lahore, memories of our time in the hills lingered. The trip was a perfect blend of adventure, relaxation, and rejuvenation. Highlights: - Scenic drive to Murree - Exploring Mall Road and local cuisine - Breathtaking views ...

Good Morning Wishes

Bollywood actor Dharmendra has passed away at the age of 89

Legendary Bollywood actor Dharmendra has passed away at the age of 89.  R. I. P The 'He-Man' of Indian cinema, known for his iconic roles in films like 'Sholay', 'Seeta Aur Geeta', and 'Dharam Veer', breathed his last on November 24, 2025, in Mumbai. Dharmendra's career spanned over six decades, with more than 300 films to his credit. He was a recipient of the Filmfare Lifetime Achievement Award and the Padma Bhushan, among other accolades. His family, friends, and fans are mourning his loss, remembering him as a kind soul and an unforgettable icon of Indian cinema.