C Program to check leap year

A year will be leap year:- (i) If it is divisible by 400 (ii) If it is divisible by 4 but not by 100. If a year is divisible by 4 and by 100 it is not leap year unless it is divisible by 400. For example 1900 is not a leap year but 1904 is a leap year.
#include<stdio.h>
int main()
{
 int n;
 printf("Enter a year: ");
 scanf("%d",&n);
 if(n%400==0)
 {
  printf("%d is a leap year \n",n);
 }
 else
 if(n%4==0)
 {
  if(n%100==0)
  {
   printf("%d is not a leap year \n",n);
  }
  else
  {
   printf("%d is a leap year \n",n);
  }
 }
 else
 {
  printf("%d is not a leap yearr \n",n);
 }
 return 0;
}







Popular posts from this blog