Answer:
void season(char * month, int day){
if(strcpy(month, "January") == 0 || strcpy(month, "February") == 0)
printf("Winter\n");
else if(strcpy(month, "March") == 0){
if(day < 20)
printf("Winter\n");
else
printf("Spring\n");
}
else if(strcpy(month, "April") == 0 || strcpy(month, "May") == 0)
printf("Spring\n");
else if(strcpy(month, "June") == 0){
if(day < 20)
printf("Spring\n");
else
printf("Summer\n");
}
else if(strcpy(month, "July") == 0 || strcpy(month, "August") == 0)
printf("Summer\n");
else if(strcpy(month, "September") == 0){
if(day < 20)
printf("Summer\n");
else
printf("Autumn\n");
}
else if(strcpy(month, "October") == 0 || strcpy(month, "November") == 0)
printf("Autumn\n");
else if(strcpy(month, "December") == 0){
if(day < 20)
printf("Autumn\n");
else
printf("Winter\n");
}
}
Explanation:
I am going to write a C program for this.
I am going to use the function strcpy, from the library string.h, to compare strings. It returns 0 when strings are equal.
I am going to say that the season change happens at day 20, in March, June, September and December
void season(char * month, int day){
if(strcpy(month, "January") == 0 || strcpy(month, "February") == 0)
printf("Winter\n");
else if(strcpy(month, "March") == 0){
if(day < 20)
printf("Winter\n");
else
printf("Spring\n");
}
else if(strcpy(month, "April") == 0 || strcpy(month, "May") == 0)
printf("Spring\n");
else if(strcpy(month, "June") == 0){
if(day < 20)
printf("Spring\n");
else
printf("Summer\n");
}
else if(strcpy(month, "July") == 0 || strcpy(month, "August") == 0)
printf("Summer\n");
else if(strcpy(month, "September") == 0){
if(day < 20)
printf("Summer\n");
else
printf("Autumn\n");
}
else if(strcpy(month, "October") == 0 || strcpy(month, "November") == 0)
printf("Autumn\n");
else if(strcpy(month, "December") == 0){
if(day < 20)
printf("Autumn\n");
else
printf("Winter\n");
}
}