1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
pav-90 [236]
3 years ago
10

In C Coding, print either "Fruit", "Drink", or "Unknown" (followed by a newline) depending on the value of userItem. Print "Unkn

own" (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
Sorry in advance, I'm new and my professor has been a bit hard to understand so I'd like a walkthrough on this problem.
Computers and Technology
1 answer:
shutvik [7]3 years ago
6 0

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:

brainly.com/question/17592042

You might be interested in
What allows you to navigate up down left and right in a spreadsheet?
scoray [572]

Answer:

scrollbar?

Explanation:

____________

5 0
3 years ago
Go to the Creamy Ice Corporation passage on the next page. Insert the trademark sign after the word “Corporation'' in the first
GuDViN [60]

Answer:

v

Explanation:

because it is

5 0
4 years ago
The utility ___ is a map that connects each possible bundle to the corresponding level of utility that a person gets from consum
docker41 [41]

Answer:

function

Explanation:

Utility depicts the satisfaction that a user gets in consuming a good or service.  It can be in the form of form, time, possession and place.

Utility function is used to measure how a user behaves when they receive or consume a product or service relative to how they behave when they receive other products/services. It is a widely used tool for measuring users' preferences over a series of products/services. It can be thought of as a map that connects each possible bundle of service to the corresponding utility that a person will get from consuming it.

With utility function, companies can track the way their products/services are being viewed by consumers thus allowing them to make logical business decisions.

3 0
3 years ago
What is adware?
Mila [183]

Software that, while purporting to serve some useful function and often fulfilling that function, also allows Internet advertisers to display advertisements without the consent of the computer user.

7 0
3 years ago
____________________ is like a set of instructions that helps hardware process data into information.
Arte-miy333 [17]

Answer:

Program

Explanation:

Program is like a set of instructions that helps hardware process data into information.

Every hardware needs a program to process data into information.

For example take the example of a data processing software like MS Excel.

You open a spreadsheet and enter some data into your sheet. and then ask the program to do some calculations with this data and give you output results. The spreadsheet software does this processing in the background for you and provides you the results.

Without program a hardware doesn't know what to do with the data. Therefore, a program is like a instruction set that guides the hardware what to do with the data.

Note: The terms software and program are usually used together but there is a difference between software and program

A software is a generalized term and program is more like a specific term.

software can be made up of several different programs which performs many different tasks. On the other hand, a program only carry out a specific task or set of instructions.

3 0
4 years ago
Other questions:
  • The Mesozoic is known as the _________
    7·1 answer
  • Jacob is a website designer. Whenever his company takes on a new project, Jacob takes the initiative and comes up with ideas and
    12·1 answer
  • the list of available fonts in the fonts gallery may differ, depending on what fonts you have installed and the type of printer
    14·1 answer
  • Kelly completes a bachelor's degree in animation from a top school in New York. She would now like to look for a job that will p
    5·2 answers
  • A certain program takes 26.67 seconds to run on 3 processors and 16 s to run on 7 processors. Find the execution time on one pro
    10·1 answer
  • Features of action files​
    15·1 answer
  • Karen wants to create a program that will allow the user to input their age. Which of these lines of code should be used?
    11·1 answer
  • Which option is the default when creating appointments and meetings in a user’s own calendar as it relates to Free/Busy informat
    8·1 answer
  • Larry has created a web page using HTML 4.01. He hasn’t included the declaration in the file. When he opens the page in a browse
    8·1 answer
  • The linux/unix command __________ can be used to search for files or contents of files.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!