The code below uses if-else structure to print the output depending on the value of the userItem.
If the specified condition in the if structure is true, the block in the structure gets executed.
Comments are used to explain the each line of the code.
//main.c
#include <stdio.h>
int main()
{
//defining the enum and userItem
enum GroceryItem {GR_APPLES, GR_BANANAS, GR_JUICE, GR_WATER};
enum GroceryItem userItem;
//initializing the userItem
userItem = GR_APPLES;
//checking the userItem
//If it is GR_APPLES or GR_BANANAS, print "Fruit"
//If it is GR_JUICE or GR_WATER, print "Drink"
//Otherwise, print "Unknown"
if(userItem == GR_APPLES || userItem == GR_BANANAS){
printf("%s\n", "Fruit");
}
else if(userItem == GR_JUICE || userItem == GR_WATER){
printf("%s\n", "Drink");
}
else{
printf("%s\n", "Unknown");
}
return 0;
}
You can see a similar question at:
https://brainly.com/question/17592042