condition for leap year with c programimg

if a year is divided by 400 then it is a leap year and if it is divided by 100 then it is not a leap year and if it is divided by 4 then it is a leap year else it is not a leap year

some years are divisible by 4 but they are not leap year so we are dividing with both 400 and 4

ex-1700, 1800, 1900, 2100, 2200, 2300, 2500, 2600
This is because they are evenly divisible by 100 but not by 400.
The following years are leap years:
1600, 2000, 2400
This is because they are evenly divisible by both 100 and 400.

C programming code
#include <stdio.h>
int main()
{
int year;
printf(“Enter a year to check if it is a leap yearn”);
scanf(“%d”, &year);
if ( year%400 == 0)
printf(“%d is a leap year.n”, year);
else if ( year%100 == 0)
printf(“%d is not a leap year.n”, year);
else if ( year%4 == 0 )
printf(“%d is a leap year.n”, year);
else
printf(“%d is not a leap year.n”, year);
ret

Leave a Comment

Your email address will not be published. Required fields are marked *

Hire a server Expert to resolve the issue Now.

Hire a server Expert to resolve the issue Now.

Resolve this issue in just 5$ from https://serverexpert.io

 

You have Successfully Subscribed!

Open chat