-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathleapYearFunction.c
48 lines (38 loc) · 917 Bytes
/
leapYearFunction.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//Name: Augusdn
//Date: 31 March 2015
//Program that test for leap year with leapYearFunction
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#define START_OF_GREG_CALENDAR 1582
int isLeapYear (int year);
int year;
int main (int argc, char* argv[]){
printf ("please enter the year you are interested in\n");
scanf ("%d", &year);
assert (year >= START_OF_GREG_CALENDAR);
if (isLeapYear(year) == 0){
printf ("%d is not a leap year!\n", year);
}
if (isLeapYear(year) == 1){
printf ("%d is a leap year!\n", year);
}
return EXIT_SUCCESS;
}
int isLeapYear (int year) {
int isLeapYear;
if ((year % 4) == 0){
if (year % 100 == 0){
if (year % 400 == 0){
isLeapYear = 1;
} else {
isLeapYear = 0;
}
} else {
isLeapYear = 1;
}
} else {
isLeapYear = 0;
}
return (isLeapYear);
}