Key Features

Experienced Teachers
Smart Classes
Regular Test
Study Material

Well qualified teachers with industrial experience.

To visualise or understand topics very easly.

We are organizing online and offline regular test.

We are providing prescribed study material.

Friday, October 30, 2020

Question : Write a C Program to check whether a year is leap year or not.


 Question :  Write a C Program to check whether a year is leap year or not.

/*
Write a C Program to check whether a year is leap year or not.
*/

#include <stdio.h>
int main()
{
            int year;
            printf("Enter a year: ");
            scanf("%d", &year);
            if (year % 4 == 0)
{
                        if (year % 100 == 0)
{
                                    // the year is a leap year if it is divisible by 400.
                                                if (year % 400 == 0)
                                    {
                                     printf("%d is a leap year.", year);
                                    }
                                     else
{          
                                    printf("%d is not a leap year.", year);
                                    }
                         }
else
{
                                    printf("%d is a leap year.", year);
}
            }
else
{
            printf("%d is not a leap year.", year);
            }
    return 0;
}

OUTPUT :
Enter a year: 1900
1900 is not a leap year.

Thank you very much for reading carefully, if you have any other questions, you can share it with us through comments, if this information was important to you, please let us know through comments.

Please do comment and share.
Thank You.

No comments:

Post a Comment