Leap Year Returned :P

code:

#include<stdio.h>
int main()
{
    int year,x;
    printf("Enter year:");
    scanf("%d",&year);
    //((year%4==0&&year%100!=0)||(year%400==0))?:printf("%d is not leap year.",year);
    x=((year%4==0&&year%100!=0)||(year%400==0))?1:0;
    if(x==0)
    {
        printf("%d is not leap year",year);
    }
    else
    {
        printf("%d is leap year",year);
    }

    return 0;
}

Leap Year Logic:

Exactly Which Years Are Leap Years?

We add a Leap Day on February 29, almost every four years. The leap day is an extra, or intercalary, day and we add it to the shortest month of the year, February.

In the Gregorian calendar three criteria must be taken into account to identify leap years:

  • The year can be evenly divided by 4;
  • If the year can be evenly divided by 100, it is NOT a leap year, unless;
  • The year is also evenly divisible by 400. Then it is a leap year.

This means that in the Gregorian calendar, the years 2000 and 2400 are leap years, while 1800, 1900210022002300 and 2500 are NOT leap years.
source: https://www.timeanddate.com/date/leapyear.html

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

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