C Program to Check Leap Year

Program to Check Leap Year

  1.   #include <stdio.h>
  2.   int main() {
  3.   int year;
  4.   printf("Enter a year: ");
  5.   scanf("%d", &year);
  6.   if (year % 4 == 0) {
  7.   if (year % 100 == 0) {
  8.   // the year is a leap year if it is divisible by 400.
  9.   if (year % 400 == 0)
  10.   printf("%d is a leap year.", year);
  11.   else
  12.   printf("%d is not a leap year.", year);
  13.   } else
  14.   printf("%d is a leap year.", year);
  15.   } else
  16.   printf("%d is not a leap year.", year);
  17.   return 0;
  18.  }