Example 11: Check if a Given Year Is a Leap Year
Learn to identify a leap year using conditional statements.
We'll cover the following...
We'll cover the following...
Problem
Write a program that takes a year as an input and decides and then prints whether it is a leap year or not.
You should print the output on the console in the following manner:
- Leap year
- Not a leap year
Example
| Input | Output |
|---|---|
| 1984 | Leap Year |
| 2005 | Not a leap year |
| 1800 | Not a leap year |
| 2000 | Leap Year |
Try it yourself
Try to solve this question on your own in the code widget below. If you get stuck, you can always refer to the solution provided.