This code is shared by Deepak Gupta, thanks for your contribution. share your code with us we will post them here..
A leap year (or intercalary or bissextile year) is a year containing one extra day.
Here is the Program to check whether a given year is leap year or not.
Output:
Eter the year:
2011
year 2011 is not a leap year.
Code:
A leap year (or intercalary or bissextile year) is a year containing one extra day.
Here is the Program to check whether a given year is leap year or not.
Output:
Eter the year:
2011
year 2011 is not a leap year.
Code:
//C Program to check whether a given year is leap year or not.
#include<stdio.h>
#include<conio.h>
void main()
{
int yr;
clrscr();
printf("Enter the year:\n");
scanf("%d",&yr);
if((yr%400==0)||(yr%400!=0)&&(yr%4==0))
{
printf("year %d is a leap year",yr);
}
else
{
printf("year %d is not a leap year",yr);
}
getch();
}
Hope you liked the posts, give comments if you have any doubts.. :)#include<stdio.h>
#include<conio.h>
void main()
{
int yr;
clrscr();
printf("Enter the year:\n");
scanf("%d",&yr);
if((yr%400==0)||(yr%400!=0)&&(yr%4==0))
{
printf("year %d is a leap year",yr);
}
else
{
printf("year %d is not a leap year",yr);
}
getch();
}
Categories:
c program
,
tricky code
2 comments:
you can simplify it like this. there is no need of %400 like that
#include
#include
void main()
{
int yr;
clrscr();
printf("Enter the year:\n");
scanf("%d",&yr);
if(yr%4==0)
printf("year %d is a leap year",yr);
else
printf("year %d is not a leap year",yr);
getch();
}
Exactly...no need to complex the program
Post a Comment