Pages

Program to find Leap year

We can determine the leap year by applying the condition whether the given year is divisible by 4 and not divisible by 100 or given year is divisible by 400. If the condition satisfies then the given is leap year.

leap_year.c

#include <stdio.h>
#include <conio.h>

void main()
{
    int year;
    printf("Enter Year : ");
    scanf("%d", &year);
 
   //check for leap year.
   if((year % 4 == 0 && year %100 != 0) || (year % 400 == 0))
       printf("\n %d is Leap Year", year);

  else
      printf("\n%d is not Leap Year",year);
   getch();
}


Output:
Enter year : 2012
2012 is Leap Year.

@msucil

Phasellus facilisis convallis metus, ut imperdiet augue auctor nec. Duis at velit id augue lobortis porta. Sed varius, enim accumsan aliquam tincidunt, tortor urna vulputate quam, eget finibus urna est in augue.

No comments:

Post a Comment