Q3 Any year is input through the keyboard. Write a program to determine whether the year is a leap year or not.

Any year is input through the keyboard. Write a program to determine whether the year is a leap year or not.

Program: 71

Any year is input through the keyboard. Write a c program to determine whether the year is a leap year or not.

#include<stdio.h>
#include<conio.h>
int main()
{
    int year;

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

    //if year is completely divisible via 4
    if (year % 4 == 0)
    {
        //if year is completely divisible via 4 and 100
        if (year % 100 == 0)
        {
            //if year is completely divisible via 4, 100, and 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 the Year: 2020
 2020 is a Leap Year

Lokesh Kumar: Being EASTER SCIENCE's founder, Lokesh Kumar wants to share his knowledge and ideas. His motive is "We assist you to choose the best", He believes in different thinking.

View Comments (2)

Related Post
Leave a Comment

This website uses cookies.