Tuesday, March 5, 2024

2. Input a year and check it is leap year or not :—

 


2. Input a year and check it is leap year or not :—


#include<stdio.h>

int main()

{

    int y;

    printf("enter a year ");

    scanf("%d",&y);

    if(y%4==0)

    {

        if(y%100==0)

        {

            if(y%400==0)

            {

                printf("%d is leap year",y);

            }

            else

            {

                printf("%d is not leap year",y);

            }

        }

        else

        {

            printf("%d is leap year",y);

        }

    }

    else

    {

        printf("%d is not leap year",y);

    }

    return 0;

}


No comments:

Post a Comment