-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogram13-1.c
50 lines (41 loc) · 933 Bytes
/
program13-1.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
49
// Program to print the number of days in a month
#include <stdio.h>
int main(void)
{
enum month { January = 1, February, March,
April, May, June, July, August, September,
October, November, December};
enum month aMonth;
int days;
printf("Enter month number: ");
scanf("%i", &aMonth);
switch (aMonth) {
case January:
case March:
case May:
case July:
case August:
case October:
case December:
days = 31;
break;
case April:
case June:
case September:
case November:
days = 30;
break;
case February:
days = 28;
break;
default:
printf("bad month number\n");
days = 0;
break;
}
if (days != 0)
printf("Number of days is %i\n", days);
if (aMonth == February)
printf("...or 29 if it's a leap year\n");
return 0;
}