Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdbool.h>
- bool isLeapYear(int year) {
- if (year < 1582) return false;
- return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0));
- }
- int main(void) {
- int i, years[] = {2000, 2001, 2002, 2003, 2004, 2005, 2100, 2200, 2300, 2400};
- for (i = 0; i < (int) sizeof(years) / sizeof(int); i++) {
- printf("%d is %s.\n", years[i],
- (isLeapYear(years[i]) ? "leap year" : "not leap year"));
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement