Leap Year Program in C Using If Else

Leap year or not in c using if else for beginners. This program will print the leap year or not program in c program. 

How to check the year is leap year or not program in c language. This will check the year leap or not by %4 with the year.

#include<stdio.h>
int main()
{
int year;
printf("Enter the year");
scanf("%d", &year);
if (year % 400 == 0)
{
printf("%d is a leap year", year);
}
else if (year % 100 == 0)
{
printf("%d is not leap year", year);
}
else if (year % 4 == 0)
{
printf("%d is a leap year", year);
}
else
{
printf("%d is not leap year", year);
}
return 0;
}

 

Output

Enter the year

2020

2020 is a leap year

If Else Statement in C

In C, the if-else statement is used to carry out operations based on a set of conditions. 

If and only if the supplied condition is true, the operations stated in the if block are executed.

Leap Year and Why It Happens Every Four Years

The Earth’s orbit around the Sun takes around 365.25 days – a solar year. The days in a calendar year are commonly rounded to 365. 

Every four years, we add one day to our calendar to compensate for the missing partial day. 

There are 366 days in a year, so there are 366 days in a year. This is referred to as a leap year. 

To understand the concept and to implement program like leap year program in c is for beginners in computer programming.

Why February Month is Leap Year

Because February was the last day of the year, an extra date was added in February to ensure that the first day of spring always coincided with the correct time. 

A leap year occurs every four years on average, but there are outliers. If a year is equally divisible by four, it is a leap year. Using this program we can find the leap year or not in c.