forked from pragati-dhingra/the-book-of-c
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pg077_q013.c
42 lines (38 loc) · 1.13 KB
/
pg077_q013.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
#include <stdio.h>
int main (int argc, char* argv[] ){
/* Write a program that reads the month number (1-12) and prints its equivalent name (January for 1, February for 2, and so on).
Input: One integer on a line, e.g. 4
Output: Correponding name of month, e.g. April
Please do not use abbreviations. First character is capital, rest are small case, no trailing newline
In case of invalid input, output should be "Invalid" (without quotes)
Output is case sensitive */
int month=0;
scanf("%d",&month);
if (month==1){
printf("January");
}else if (month==2){
printf("February");
}else if (month==3){
printf("March");
}else if (month==4){
printf("April");
}else if (month==5){
printf("May");
}else if (month==6){
printf("June");
}else if (month==7){
printf("July");
}else if (month==8){
printf("August");
}else if (month==9){
printf("September");
}else if (month==10){
printf("October");
}else if (month==11){
printf("November");
}else if (month==12){
printf("December");
}else if (month<1 || month>12){
printf("Invalid");
}
}