Skip to content

Instantly share code, notes, and snippets.

@scratchyourbrain
Created December 16, 2014 04:13
Show Gist options
  • Save scratchyourbrain/62a4cf787f058e47de8e to your computer and use it in GitHub Desktop.
Save scratchyourbrain/62a4cf787f058e47de8e to your computer and use it in GitHub Desktop.
C Program to Check Leap Year
#include <stdio.h>
int main()
{
int year;
printf("Enter a year: ");
scanf("%d",&year);
if(year%4 == 0)
{
if( year%100 == 0) /* Checking for a century year */
{
if ( year%400 == 0)
printf("%d is a leap year.", year);
else
printf("%d is not a leap year.", year);
}
else
printf("%d is a leap year.", year );
}
else
printf("%d is not a leap year.", year);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment