Created
December 12, 2017 13:58
-
-
Save awmpietro/281eac6e4973381ffd978cde2fd88185 to your computer and use it in GitHub Desktop.
Calculate a leap year in C
This file contains hidden or 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
| int main() { | |
| int year; | |
| printf("Enter year"); | |
| scanf("%d", &year); | |
| if(year % 4 == 0) { | |
| if(year % 100 == 0) { | |
| if(year % 400 == 0) { | |
| printf("Yes, the year is leap year\n"); | |
| } else { | |
| printf("No, this is not a leap year\n"); | |
| } | |
| } else { | |
| printf("Yes, the year is leap year\n"); | |
| } | |
| } else { | |
| printf("No, this is not a leap year\n"); | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)) printf("Yes, the year is leap year\n");