by Dinesh Thakur Category: C Programming (Pratical)

A year is leap if it is divisible by 4 but not by 100 or is divisible by 400. Thus, 1996, 2000 and 2004 are leap years but 1900, 2002 and 2100 are not. The program segment given below determines whether a given year (of type int) is leap or not.

#include<stdio.h>
#include<conio.h>
void main()
{
       int year;
       clrscr();
       printf("Enter a Year : ");
       scanf("%d",&year);
       if(year%4==0&&year%100!=0||year%400==0)
         {
              printf("Leap Year");
          }
       else
         {
              printf("Not a Leap Year");
          }
              getch();  
}
Output :
Enter a Year : 2013
Not a Leap Year


About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.