# Leap Year Program

Nearly every four years is a leap year.

A leap year, which was invented by Julius Caesar and later corrected during the introduction of the Gregorian calendar, has 366 days instead of the usual 365 days in the Gregorian Calendar ( a calendar introduced by Pope Gregory XIII). It takes the earth about 365.24 days to orbit around the sun. The normal 365 days is about 1/4 short of a complete rotation, and a leap year is about 3/4 days over a tropical year.

More specifically it takes the earth about 365.242189 days or 365 days, 5 hours, 48 minutes and 45 seconds to orbit around the sun. The Gregorian calendar (a.k.a the most widely used calendar in the world today) only has 365 days in a year and so if we did not add the extra day (a leap day) on February 29 NEARLY every 4 years, we would lose about 6 hours off the calendar every year. This means after one hundred years, the calendar would be off by about twenty four days.

# Leap Year Criteria

There are 3 criteria that must be taken into account to identify a leap year.

1. If the year can be evenly divided by 4 then it is a leap year
2. If the year can be evenly divided by 100, and it is not evenly divided by 400, then it is NOT a leap year.
3. If the year is evenly divisible by 400, then it is a leap year

# Leap Year Examples:

1. Year 2000 was a leap year
2. Year 2400 will be a leap year
3. Year 1800 was not a leap year
4. Year 1900 was not a leap year

The year 2000 was a very special year because it was the first time that the 3rd criteria was ever used since the transition from the Julian calendar (a calendar proposed by Julis Caesar) to the Gregorian calendar.

# Leap Year C-Program

Let’s create a program that will determine if a year is a leap year or not using the leap year criteria.

First we will ask the user to enter an integer value for the year after creating our main function.

Now that we have the users input in the variable called “year”, lets use if statements to check the criteria for the year needed to be a leap year. First we check criteria #3, then we check criteria #2 and finally check criteria #1. Lastly we have an else statement to print that if the year did not meet the criteria, then it is not a leap year.

That’s pretty much it, you can get the source code on my github account randerson112358.

Thanks for reading this article I hope its helpful to you all ! Keep up the learning, and if you would like more computer science, programming and algorithm analysis videos please visit and subscribe to my YouTube channels (randerson112358 & compsci112358 )

# Check Out the following for content / videos on Computer Science, Algorithm Analysis, Programming and Logic:

compsci112358:

Video Tutorials on Recurrence Relation:

Video Tutorial on Algorithm Analysis:
https://www.udemy.com/algorithm-analysis/

Written by