C program to print whether a year is leap or not

C program to print whether a year is leap or not. 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

What is if else statement in c program

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.

What is 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.

Why febraury 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.