What is a Leap Year?
"A leap year is a calendar year that contains an additional day added to keep the calendar year synchronized with the astronomical year or seasonal year." ~ Wikipedia
A Non-Leap year contains 365 days in a year while a Leap Year contains 366 days in a year.
In terms of programming logic, a leap year,
- should be divisible by 400 (In case of century years) .
- and, should be divisible by 4 (In case of non-century years).
Given a year, we have to check whether it is a leap year or not.
Example:
Input:
2020
Output:
2020 is Leap Year
Input:
2021
Output:
2021 is Not a Leap Year
Program to check leap year in Kotlin
Output
need an explanation for this answer? contact us directly to get an explanation for this answer