Hello Readers!! Today, we will learn how to check whether a year is a leap year or not in C++.
A year is called a Leap Year when the year has 366 days. It occurs after every 4 years.
A year is said to be a Leap Year when the below conditions are met :
1) If the year is a multiple of 400.
2) If the year is a multiple of 4 and not a multiple of 100.
The program firstly takes the input from the user. The input is actually the year which we want to check whether it is a leap year. Then, the above 2 conditions are matched with the user given year. In the end, the final verdict is made based on the result. For example, the year 2000 is divisible by 400, thus it is a leap year. The year 2016 is divisible by 4 but not completely divisible by 100, so it is also a leap year.
Submitted by Vidhu Shekhar Tripathi (Vidhu27)
Download packets of source code on Coders Packet