# Thread: Program showing if a year its leap year or not.

1. ## Program showing if a year its leap year or not.

I need to make a program that can shows if it a year is leap year or not, I couldn't understand exactly what my teacher said because of his accent but I think he said this:

"If the Input is four digits number integer tell if its leap year or not."

This is the only Programming class i have to take and Is part of my course, I'm studying electronics engineering but my Teacher can't speak English well.

Where can I see code examples like this one or if you can post the code i can read throught it and analize it. This won't be graded is just practice.

2. Figure out how you'd solve it in real life. If I asked you, "Was 1048 a leap year? How about 1900? How about 2800? What about 7653?" How would you answer those questions?

Once you've figured out the algorithm for solving those questions by hand (or in your head) all you have to do is apply that algorithm to your code.

3. A leap year has a property that it's divisible by 4. Divisibility by 4 means that you can check for the last two digits (the least significant) to be divisible by 4 as well.

That's what you need to implement .... Check if a number is divisible by 4 .... If it is, then it's a leap year otherwise not .....

4. Originally Posted by gvkalra
That's what you need to implement .... Check if a number is divisible by 4 .... If it is, then it's a leap year otherwise not .....
It's not as straight forward as that: link

Nor will we write the code for you to
Originally Posted by Cyberman86
analize
QuantumPete

5. So, the rule is:
A year is a leap year if it is divisiible by 4, not divisible by 100 unless it is also an even 400 year (so year 2000 was a leap-year, 1900 was not).

To be calendarically correct, you would also have to take into account that some hundreds of years ago, there were no leap-years. But I think we can ignore that for now - and that is why the date in September (I think) some 3-400 years ago went forward about 11 days.

--
Mats

6. Originally Posted by matsp
So, the rule is:
and that is why the date in September (I think) some 3-400 years ago went forward about 11 days.
In fact it was a little more recent than that in some places: The October Revolution was actually in November according to our Gregorian Calendar.

QuantumPete