Home » » C Program For Detection of Leap year using Functions.

C Program For Detection of Leap year using Functions.

C Program For Detection of Leap year using Functions.
Any year is entered through the keyboard.

Write a function to determine whether the year is a leap year or not.

#include
main()
{

int leap_year(year);
int year, lp;

printf("Enter the year:");
scanf ("%d", &year);

lp=leap_year(year);

if (lp)

{
printf("\nThe entered year is a leap year.");
}
else
{

printf("\nThe entered year is not a leap year.");
}

}


leap_year(int y)

{
int lp;

if (y%4==0)

{
lp=1;
}
else
lp=0;

return(lp);
}


0 comments:

Post a Comment