C Program To Check Year Is Leap Year Or Not Using If/Else Statements

#include <stdio.h>
int yr;
  printf ("Enter a year n");
  scanf ("%d", &yr);
  if (yr%4 == 0) {
      if(yr%100 == 0) {
          if(yr%400 == 0)
             printf("n It is LEAP YEAR.");
          else
             printf("n It is NOT LEAP YEAR.");
      }
      else {
             printf ("n It is LEAP YEAR.");
      }
  }
  else
      printf("n It is NOT LEAP YEAR.");
return 0;
}

Output:

Enter a year
2004
It is LEAP YEAR.
Sharing Is Caring

Leave a Comment