Q:

C PROGRAM TO FIND LEAP YEAR

0

C PROGRAM TO FIND LEAP YEAR:

What is leap year?

Leap year is a year which has 366 days. Leap year occurs once every 4 years.

How to find whether a year is leap year or not using a C program?

* A year which can be exactly divisable by 4 except century years is called leap year.

* Century year means the year which ends with 00. Century year also can be a leap year if it is exactly divisable by 400.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include 
 
int main()
 
{
 
  int year;
 
  printf("\nPlease enter a year to check whether it is a leap year or not");
 
  scanf("%d", &year);
 
 
 
  if ( year%400 == 0)
 
    printf("\n%d is a leap year", year);
 
  else if ( year%100 == 0)
 
    printf("\n%d is not a leap year", year);
 
  else if ( year%4 == 0 )
 
    printf("\n%d is a leap year", year);
 
  else
 
    printf("\n%d is not a leap year", year);  
 
  return 0;
 
}

Please enter a year to check whether it is a leap year or not 2

2 is not a leap year

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now