Created
April 1, 2021 07:08
-
-
Save chris-pws/68fa60d5eae789b765cca57fb75bfd73 to your computer and use it in GitHub Desktop.
Leap year
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
int numDays(int month, int year) | |
{ | |
if ( (month == 1 ) || (month == 3 ) || (month == 5 ) || (month == 7 ) || (month == 8 ) || | |
(month == 10 ) || (month == 12 ) ) | |
{ | |
return 31; | |
} | |
if (month == 2) | |
{ | |
if ( year % 4 != 0 ) | |
{ | |
return 28; | |
} | |
else if ( year % 100 != 0 ) | |
{ | |
return 29; | |
} | |
else if ( year % 400 != 0 ) | |
{ | |
return 28; | |
} | |
else | |
{ | |
return 29; | |
} | |
} | |
return 30; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment