Header Ads Widget

c program to check a year is leap year or not

here in this post we will write a program to check the leap year . So first of all we have to know that what is a leap year .. Generally A year is called leap year if it is divisible by 4 . But if the year is divisible by 100 then in this case  we have to check that if year is divisible by 400 then it is called leap year .. So Conclusion is that if a year is divisible by 100 then we have to check that if year is divisible by 400 then is a leap year other wise if it is not divisible by 100 then we will check that if year is divisible 4 then it is a leap year .
So C program for checking a year is leap year or not given below.

C program for leap year :-

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

Output:-

Enter the year: 1700
1700 is a not leap year

keyword:-

,write a program to check if the year entered by the user is a leap year or not,

,leap year program in c in one line,

,how to check leap year,

,leap year program in c using if else,

,write a program to check leap year in python,

,leap year program in c using function,

,flowchart for leap year program in c,

,write a program to check leap year in java,

,leap year program in c in one line,

,leap year program in c using if else,

,leap year program in c using function,

,flowchart for leap year program in c,

,how to check leap year,

,write a program to check leap year in python,



Recommended Post:

Full C course:-    

Key points:-

Cracking the coding interview:-

 Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

 MCQs:-

Post a Comment

0 Comments