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
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
Chapter3: Using Methods, Classes, And Objects
Section: Chapter Questions
Problem 12RQ
Related questions
Question
IN C
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
Knowledge Booster
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.Recommended textbooks for you
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT