- #1
needOfHelpCMath
- 72
- 0
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
Fruit
Code:
#include <iostream>
using namespace std;
int main() {
enum GroceryItem {GR_APPLES, GR_BANANAS, GR_JUICE, GR_WATER};
GroceryItem userItem = GR_APPLES;
userItem = GR_APPLES;
while ( userItem != GR_APPLES) {
if (userItem == GR_APPLES) {
cout << userItem << "Fruit" << endl;
}
}
return 0;