Practice

Leap Year Checker

HARDSelection

Read a year. Output Leap Year if it is a leap year, or Not a Leap Year otherwise.

Rules:

  • Divisible by 400 → Leap Year
  • Divisible by 100 (but not 400) → Not a Leap Year
  • Divisible by 4 (but not 100) → Leap Year
  • Otherwise → Not a Leap Year

Input: A positive integer year. Output: Leap Year or Not a Leap Year.

Example:

Input:  2024
Output: Leap Year

Sample Test Cases

Test 1: Divisible by 400
Inputs: 2000
Expected: Leap Year
Test 2: Div by 100, not 400
Inputs: 1900
Expected: Not a Leap Year
Test 3: Divisible by 4
Inputs: 2024
Expected: Leap Year
Test 4: Not divisible by 4
Inputs: 2023
Expected: Not a Leap Year

Premium Question

This question needs a paid plan — upgrade, or join a class from a teacher who has one. You can read the description and sample tests, but grading is locked.

Sign in to get started