Please Help with the Switch formula

I’m trying to pull a date and the switch(number) part is getting an error message

I keep getting the following error message:
$ gcc date.c
date.c: In function ‘main’:
date.c:13:3: warning: implicit declaration of function ‘Switch’ [-Wimplicit-function-declaration]
Switch(month){
^~~~~~
date.c:13:16: error: expected ‘;’ before ‘{’ token
Switch(month){

Code:

int main(void) {
int month, day, year;

// Standard date form
printf(“Enter date (mm/dd/yyyy): “);
// Split the user input into 3 variables for the date
// Don’t worry about the scanf() below, you’ll learn more about these later!
scanf(”%d /%d /%d”, &month, &day, &year);

// Print the month
Switch(month){
Case 1:
printf(“January”);
break;
Case 2:
printf(“February”);
break;
Case 3:
printf(“March”);
break;
Case 4:
printf(“April”);
break;
Case 5:
printf(“May”);
break;
Case 6:
printf(“June”);
break;
Case 7:
printf(“July”);
break;
Case 8:
printf(“August”);
break;
Case 9:
printf(“September”);
break;
Case 10:
printf(“October”);
break;
Case 11:
printf(“November”);
break;
Case 12:
printf(“December”);
break;
Default:
printf(“null\n”);
break;
}

// Print the day

// Print the suffix for a given day

// Print the year

return 0;
}

Please supply a link to the exercise page.

Hi,
The keywords switch, case and default should all be lower case.

My guess is, instead of reading Switch as the keyword as you’d expect, it’s thinking you’re trying to create a function (and the syntax for that is obviously incorrect).

Hope that helps

1 Like