-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy path19.c
More file actions
93 lines (86 loc) · 2.04 KB
/
Copy path19.c
File metadata and controls
93 lines (86 loc) · 2.04 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include <stdio.h>
#include <string.h>
int main()
{
char month[20];
printf("Enter the name of the month: ");
scanf("%s", month);
// Convert the entered month name to lowercase
for (int i = 0; i < strlen(month); i++)
{
month[i] = tolower(month[i]);
}
int days;
// Check the month name and assign the number of days
switch (month[0])
{
case 'j':
if (strcmp(month, "january") == 0)
days = 31;
else if (strcmp(month, "june") == 0)
days = 30;
else if (strcmp(month, "july") == 0)
days = 31;
else
days = -1; // Invalid month
break;
case 'f':
if (strcmp(month, "february") == 0)
days = 28;
else
days = -1; // Invalid month
break;
case 'm':
if (strcmp(month, "march") == 0)
days = 31;
else if (strcmp(month, "may") == 0)
days = 31;
else
days = -1; // Invalid month
break;
case 'a':
if (strcmp(month, "april") == 0)
days = 30;
else if (strcmp(month, "august") == 0)
days = 31;
else
days = -1; // Invalid month
break;
case 's':
if (strcmp(month, "september") == 0)
days = 30;
else
days = -1;
break;
case 'o':
if (strcmp(month, "october") == 0)
days = 31;
else
days = -1;
break;
case 'n':
if (strcmp(month, "november") == 0)
days = 30;
else
days = -1;
break;
case 'd':
if (strcmp(month, "december") == 0)
days = 31;
else
days = -1;
break;
default:
days = -1;
break;
}
if (days != -1)
{
printf("Number of days in %s: %d\n", month, days);
}
else
{
printf("Invalid month\n");
}
return 0;
}