In: Computer Science
With C code
Write a switch statement (not a complete program) which prints an appropriate message for a letter code entered. Use the following messages:
If L is entered, output the message "Lakers"
If C is entered, output the message "Clippers"
If W is entered, output the message "Warriors"
If any other character is entered, output the message "invalid code"
Make sure to handle the case where the user enters in a small letter.
That is, a capital or small l should output the message “Lakers”.
printf("enter a letter code");
scanf("%c", &code);
switch(tolower(code)){
case 'l':
printf("Lakers");
break;
case 'c':
printf("Clippers");
break;
case 'w':
printf("Warriors");
break;
default:
printf("invalid code");
break;
}
NOTE: The above code snippet is in C language. Please refer to the attached screenshots for code indentation and sample I/O.
Complete Code For Reference:
Sample I/O: