-
Notifications
You must be signed in to change notification settings - Fork 16
/
18.c
36 lines (28 loc) · 717 Bytes
/
18.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
#include <stdio.h>
char *get_month_name(int month_number)
{
static char *month_names[] = {
"January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"};
if (month_number < 1 || month_number > 12)
{
return NULL;
}
return month_names[month_number - 1];
}
int main()
{
int month_number;
printf("Enter the month number (1-12): ");
scanf("%d", &month_number);
char *month_name = get_month_name(month_number);
if (month_name != NULL)
{
printf("The corresponding month is %s.\n", month_name);
}
else
{
printf("Invalid month number!\n");
}
return 0;
}