C program to check whether the year is leap year or not.

Posted by Mangesh on March 20, 2018

/* program in c to check whether the year is leap year or not. */

Description :

Leap Year :
Normally a year has 365 day. But a leap year has 366 days. 1 day extra in month of February.
Example : 2016, 2020, etc

Logic :

Leap Years are any year that can be exactly divided by 4 (such as 2012, 2016, etc) except if it can be exactly divided by 100, then it isn't (such as 2100, 2200, etc) except if it can be exactly divided by 400, then it is (such as 2000, 2400)

Program :

#include<stdio.h>
#include<conio.h>
void main()
{
  int year;
  printf("Enter the year : ");
  scanf("%d",&year);
  if(year % 400 == 0)
    printf("%d is a leap year.");
  else if (year % 4 == 0 && year %100 != 0)
    printf("%d is a leap year.");
  else
    printf("%d is not a leap year.");
  getch();
}

Output :

C program for leap year Tested in Turbo C 3.2

Written with from Mangesh.

Related Post
1 C program to check number is even or odd.
2 C program to swap to number.
3 C program to check whether the year is leap year or not.
4 C program to check whether enter alphabet is vowel or not.
Latest Post
1 C program to implement Queue using linked list.
2 C program for binary search tree (BST).
3 C program to search an element in linked list.
4 C program for postorder traversal in binary tree.
5 C program for preorder traversal in binary tree.