DESCRIPTION Create a typedef fruitType using the struct fruitType struct to store the following data about a fruit: name (string, up to 50 characters long) • color (string, up to 10 characters long) • fat (integer) • sugar (integer) • carbohydrate (integer) Write a function called getFruit that prompts the user to enter all the components of a fruitType and then returns that information in a fruitType (you can assume that the string data will not contain any spaces). Write a void function called printFruit that takes a fruitType parameter and prints the data (as shown in the examples below). In your main function, declare a 10 element array, called fruitArray of type fruitType and store the following data in the first element of fruitArray: name: banana • color: yellow fat: 1 • sugar: 15 carbohydrate: 22 then use your printFruit function to print the data in the the first element of the array. Use your getFruit function to prompt the user for the fruit data and store the results in the last element of fruitArray, then call printFruit to display the last element of the array. Define the appropriate function prototypes and function definitions. HINT: You will need the string.h package in your program and DON'T change the function names. For example, printing a fruit: Your fruit is... Fruit: banana Color: yellow Fat: 1 Sugar: 15 Carbohydrate: 22 Another example, entering fruit data then printing the fruit: Enter a fruit Fruit: Apple Color: Red Fat: 11 Sugar: 22 Carbohydrate: 33 Your fruit is... Fruit: Apple Color: Red Fat: 11 Sugar: 22 Carbohydrate: 33

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter3: Using Methods, Classes, And Objects
Section: Chapter Questions
Problem 12RQ
icon
Related questions
Question

IN C PROGRAMMING!!! Follow the prompt in the picture and make sure output matches example. 

DESCRIPTION
Create a typedef fruitType using the struct fruitType_struct to store the
following data about a fruit:
name (string, up to 50 characters long)
color (string, up to 10 characters long)
fat (integer)
sugar (integer)
• carbohydrate (integer)
Write a function called getFruit that prompts the user to enter all the components
of a fruitType and then returns that information in a fruitType (you can assume
that the string data will not contain any spaces).
Write a void function called printFruit that takes a fruitType parameter and
prints the data (as shown in the examples below).
In your main function, declare a 10 element array, called fruitArray of type
fruitType and store the following data in the first element of fruitArray:
name: banana
color: yellow
fat: 1
• sugar: 15
• carbohydrate: 22
then use your printFruit function to print the data in the the first element of the
array.
Use your getFruit function to prompt the user for the fruit data and store the results
in the last element of fruitArray, then call printFruit to display the last element
of the array.
Define the appropriate function prototypes and function definitions.
HINT: You will need the string.h package in your program and DON'T change the
function names.
For example, printing a fruit:
Your fruit is...
Fruit: banana
Color: yellow
Fat: 1
Sugar: 15
Carbohydrate: 22
Another example, entering fruit data then printing the fruit:
Enter a fruit
Fruit: Apple
Color: Red
Fat: 11
Sugar: 22
Carbohydrate: 33
Your fruit is...
Fruit: Apple
Color: Red
Fat: 11
Sugar: 22
Carbohydrate: 33
Transcribed Image Text:DESCRIPTION Create a typedef fruitType using the struct fruitType_struct to store the following data about a fruit: name (string, up to 50 characters long) color (string, up to 10 characters long) fat (integer) sugar (integer) • carbohydrate (integer) Write a function called getFruit that prompts the user to enter all the components of a fruitType and then returns that information in a fruitType (you can assume that the string data will not contain any spaces). Write a void function called printFruit that takes a fruitType parameter and prints the data (as shown in the examples below). In your main function, declare a 10 element array, called fruitArray of type fruitType and store the following data in the first element of fruitArray: name: banana color: yellow fat: 1 • sugar: 15 • carbohydrate: 22 then use your printFruit function to print the data in the the first element of the array. Use your getFruit function to prompt the user for the fruit data and store the results in the last element of fruitArray, then call printFruit to display the last element of the array. Define the appropriate function prototypes and function definitions. HINT: You will need the string.h package in your program and DON'T change the function names. For example, printing a fruit: Your fruit is... Fruit: banana Color: yellow Fat: 1 Sugar: 15 Carbohydrate: 22 Another example, entering fruit data then printing the fruit: Enter a fruit Fruit: Apple Color: Red Fat: 11 Sugar: 22 Carbohydrate: 33 Your fruit is... Fruit: Apple Color: Red Fat: 11 Sugar: 22 Carbohydrate: 33
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Structure chart
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT