In: Other
Print either "Fruit", "Drink", or "Unknown" (followed by a newline) depending on the value of userItem. Print "Unknown" (followed by a newline) if the value of userItem does not match any of the defined options. For example, if userItem is GR_APPLES, output should be:
Fruit
#include <stdio.h>
int main(void) {
enum GroceryItem {GR_APPLES, GR_BANANAS, GR_JUICE, GR_WATER};
enum GroceryItem userItem = GR_APPLES;
/* Your solution goes here */
return 0;
}
USE C PLEASE
Executable code:
C code:
#include
#include
int main()
{
enum GroceryItem {GR_APPLES, GR_BANANAS, GR_JUICE, GR_WATER};
GroceryItem userItem = GR_APPLES;
//switching into the user Input
switch(userItem)
{
//switch cases for fruits
case GR_APPLES:
case GR_BANANAS:
printf("Fruit\n");
break;
//switch cases for drinks
case GR_JUICE:
case GR_WATER:
printf("Drink\n");
break;
//default case called unknown
default : printf("Unknown\n");
break;
}
system("pause");
return 0;
}