forked from randerson112358/C-Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathisLeapYear.c
39 lines (31 loc) · 855 Bytes
/
isLeapYear.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
//Description: This program shows if a year is a leap year or not.
/*
How to know if a year is a Leap Year:
yes| Leap Years are any year that can be evenly divided by 4 (such as 2012, 2016, etc)
no | except if it can be evenly divided by 100, then it isn't (such as 2100, 2200, etc)
yes| except if it can be evenly divided by 400, then it is (such as 2000, 2400)
*/
# include <stdio.h>
int main(){
int year;
printf("Please enter a year to check if it is a leap year\n");
scanf("%d", &year);
if(year%400 == 0){
//Is leap year
printf("%d is a leap year \n", year);
}
else if(year % 100 == 0){
//is NOT leap year
printf("%d is NOT a leap year \n", year);
}
else if(year %4 == 0){
//is leap year
printf("%d is a leap year \n", year);
}
else
{
//is not leap year
printf("%d is NOT a leap year \n", year);
}
return 0;
}