In this article, we will know how do perform the C program for a leap year.
So first of all people take What is a leap year? How do you create a leap year program in c language? we will know the explanation of the program. So let’s start.
What is Leap Year
The year that comes once in every four years is 366 days. It is called a leap year. There are 365 days in such a year.
Algorithm for find leap year
- Taking an integer value by the user that will be years.
- Assign the value in that integer.
- Now we will check if the year is divisible by 4 but not by 100 then there will be “leap year“.
- Now check if the year is divisible by 400 then there will be “leap year”.
- Otherwise, “not leap year“.
C Program For A Leap Year
int main ()
printf (“Enter A Year :”);
scanf (“% d”, & y);
if (((y% 4 == 0) && (y% 100! = 0)) || (y% 400 == 0))
printf (“% d is Leap year”, y);
printf (” Not leap year”, y);
Enter Year: 2020
2020 is a leap year
Explain this program
- In this program, an integer value will be Y. In which the year will be assign, in which you have to check whether the entered year is a leap year or not.
- Now the value of y is intercepted by the user.
- Now let us use the control statement.
- In which if statement contains ((y% 4 == 0) && (y% 100! = 0)) || (y% 400 == 0) condition. In which if entered year is divisible by 4 and by 100 If not divisible and divisible by 400, then that year will be called leap year.
- Else that year will be a not leap year.