I'm trying to write a program inwhich the user enters the name of a month and the program says if this month has 30, 31 or 28/29 days. Here's the code I'm trying, the problem is that it doesn't reach all the if statement.
#include <stdio.h>
int main() {
char month;
printf("Enter a month: ");
scanf("%s", month);
if (month == "january" || month=="march"|| month == "may" || month == "july" || month == "august" || month =="october" || month == "december")
printf("This month has 31 days");
else if (month=="february")
printf("This month has 28/29 days");
else if (month == "april" || month == "june" || month == "september" || month == "november")
printf("This month has 30 days");
else
printf("Enter a valid month");
return 0;
}
Could someone please help?
Thank you in advance.
Aucun commentaire:
Enregistrer un commentaire