Created
September 19, 2017 08:44
-
-
Save kellybrookes/cb25af50dae44168e889b53ba5b3a602 to your computer and use it in GitHub Desktop.
Program to check a leap year possibility
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.