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
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
IN C

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

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

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education