Posted by admin at July 18, 2021

Leap years are years where an extra, or intercalary, day is added to the end of the shortest month, February. The intercalary day, February 29, is commonly referred to as leap day.

Leap years have 366 days instead of the usual 365 days and occur almost every four years.

Leap days keep our modern-day Gregorian calendar in alignment with Earth’s revolutions around the Sun. It takes Earth approximately 365.242189 days, or 365 days, 5 hours, 48 minutes, and 45 seconds, to circle once around the Sun. This is called a tropical year, and it starts on the March equinox.

However, the Gregorian calendar has only 365 days in a year. If we didn’t add a leap day on February 29 almost every four years, each calendar year would begin about 6 hours before the Earth completes its revolution around the Sun (see illustration).

As a consequence, our time reckoning would slowly drift apart from the tropical year and get increasingly out of sync with the seasons. With a deviation of approximately 6 hours per year, the seasons would shift by about 24 calendar days within 100 years. Allow this to happen for a while, and Northern Hemisphere dwellers will be celebrating Christmas in the middle of summer in a matter of a few centuries.

Leap days fix that error by giving Earth the additional time it needs to complete a full circle around the Sun.

The pseudocode of this algorithm sould be like this −

```
procedure leap_year()
IF year%4 = 0 AND year%100 != 0 OR year%400 = 0
PRINT year is leap
ELSE
PRINT year is not leap
END IF
end procedure
```

```
include
int main() {
int year;
printf("Enter a year: ");
scanf("%d", &year);
// leap year if perfectly divisible by 400
if (year % 400 == 0) {
printf("%d is a leap year.", year);
}
// not a leap year if divisible by 100
// but not divisible by 400
else if (year % 100 == 0) {
printf("%d is not a leap year.", year);
}
// leap year if not divisible by 100
// but divisible by 4
else if (year % 4 == 0) {
printf("%d is a leap year.", year);
}
// all other years are not leap years
else {
printf("%d is not a leap year.", year);
}
return 0;
}
```

```
Python program to check if year is a leap year or not
year = 2000
To get year (integer input) from the user
year = int(input("Enter a year: "))
if (year % 4) == 0:
if (year % 100) == 0:
if (year % 400) == 0:
print("{0} is a leap year".format(year))
else:
print("{0} is not a leap year".format(year))
else:
print("{0} is a leap year".format(year))
else:
print("{0} is not a leap year".format(year))
```

```
// program to check leap year
function checkLeapYear(year) {
````//three conditions to find out the leap year if ((0 == year % 4) && (0 != year % 100) || (0 == year % 400)) { console.log(year + ' is a leap year'); } else { console.log(year + ' is not a leap year'); }`

}
// take input
const year = prompt('Enter a year:');
checkLeapYear(year);

## Comments