Program
Write a program to find out if a given year is a leap year or not.
e.g. 2000, 2004, 2008, 2012, 2016, 2020 etc. are leap years.
Facts
- A normal year has 365 days but a leap year has 366 days.
- An extra day in leap is due to 29 days in February instead of 28 days.
Algorithm
Check out flowchart showing the Leap Year Algorithm
Test cases
No. | Year (Input) | Is It a Leap Year (Output) |
---|---|---|
1 | 2000 | No |
2 | 2016 | Yes |
3 | 2017 | No |
4 | 2018 | No |
5 | 2100 | No |
6 | 2400 | Yes |
Hint
- Leap years generally comes every 4 years, however, there are exceptions.
Instructions
- Define a variable to store the input year (natural number > 0).
- Write logic to determine if the year is a leap year.
- Print out the result: Yes or No.