int displayMenu ();
void displayName ();
void favColor ();
void favFood ();
int main(void)
{
int userInput;
do{
userInput=displayMenu();
switch(userInput){
case 1:
displayName();
break
case 2:
favColor();
break;
case 3:
favFood();
default:
break;
}
} while((userInput >= 1) && (userInput <= 3));
return 0;
}
int displayMenu()
{
int userInput;
puts("Choose one of the following options");
puts(" 1 - name");
puts(" 2 - favorite color");
puts(" 3 - favorite food");
printf( "Enter selection: ");
scanf("%d", &userInput);
return userInput;
}
void displayName( ) {
puts("Larry ");
}
void favColor( ) {
puts("Purple");
return;
}
void favFood( ) {
puts("Lobster");
return;
}
This code needs to be modified to use switch case statements.
# include
int displayMenu ();
void displayName ();
void favColor ();
void favFood ();
int main(void)
{
int userInput;
do{
userInput=displayMenu();
if(userInput==1){
displayName();
}
else if (userInput==2){
favColor();
}
else if (userInput==3){
favFood();
}
} while((userInput >= 1) && (userInput <= 3));
}
int displayMenu()
{
int userInput;
puts("Choose one of the following options");
puts(" 1 - name");
puts(" 2 - favorite color");
puts(" 3 - favorite food");
printf("%s","Enter selection: ");
scanf("%d", & userInput);
puts("");
return userInput;
}
void displayName(int var)
{
switch (var) {
case 1:
puts("Larry ");
puts("");
break;
}
void favColor(int var) {
switch(var) {
case 2:
puts("Purple");
puts("");
break;
}
void favFood(int var) {
switch (var) {
case 3:
puts("Lobster");
puts("");
break;
}
}
This code is not working