Friday, October 1, 2010

Checking for leap year using simple C program

int main()
{
int y;
printf("Enter a year between 1000 to 2000:");
scanf("%d",&y);
if(y%100==0)
{
if(y%400==0)
printf("It is a leap year");
else
printf("Not a leap year");
}
else
{
if(y%4==0)
printf("It is a leap year");
else
printf("Not a leap year");
}
getch();
}

No comments:

Post a Comment

Google+ Followers