๐Ÿ’ฌ Debugging & Tutorials

Leap Year Challenge Exercise

A

Anthony Olajide

Jan 2, 2026 at 2:56 PM

โ€ข 0 replies โ€ข 186 views
Image

In your preferred language, write a program that works out whether a given year is a leap year. A normal year has 365 days, and leap years have 366, with an extra day in February.

This is how to work out whether a particular year is a leap year:

[s]*[/s]A year is a leap year if it is evenly divisible by [s]**[/s]4** ;*

[s]*[/s][s]**[/s]except** if that year is also evenly divisible by [s]**[/s]100**;*

[s]*[/s][s]**[/s]unless** that year is also evenly divisible by [s]**[/s]400**.*

For more context,

Is the year 2400 a leap year?:

2400 รท 4 = 600 (Leap)

2400 รท 100 = 24 (Not Leap)

2400 รท 400 = 6 (Leap!)

So the year 2400 is a leap year.

But the year 2100 is not a leap year because:

2100 รท 4 = 525 (Leap)

2100 รท 100 = 21 (Not Leap)

2100 รท 400 = 5.25 (Not Leap)

0 Replies

Sign in to join the conversation

๐Ÿ’ญ

No replies yet

Be the first to share your thoughts on this discussion.