Skip to content

Instantly share code, notes, and snippets.

@kellybrookes
Created September 19, 2017 08:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kellybrookes/cb25af50dae44168e889b53ba5b3a602 to your computer and use it in GitHub Desktop.
Save kellybrookes/cb25af50dae44168e889b53ba5b3a602 to your computer and use it in GitHub Desktop.
Program to check a leap year possibility
#include <stdio.h>
int main()
{
int year;
printf("Enter a year: ");
scanf("%d",&year);
if(year%4 == 0)
{
if( year%100 == 0)
{
// year is divisible by 400, hence the year is a leap 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;
}
@kellybrookes
Copy link
Author

Please keep a little basic knowledge of C programming before going through this tutorial and also have a knowledge about the best web 2.0 sites.
Output of the above program:
Enter a year: 1900
1900 is not a leap year.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment