Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

An array of structures is needed to keep track of 50 grocery items containing the item name, item type, cost, quantity, and tax percentage for

An array of structures is needed to keep track of 50 grocery items containing the item name, item type, cost, quantity, and tax percentage for each grocery item. The following declarations have already been done:

struct grocery

{char name[20], type[15];

float cost, taxp;

int quan;}

Also, the following declaration has been done in the main: grocery g[50];

a. Write a program fragment to load the array of structures from a text file called ITEMS.TXT. Assume that for each grocery item, the first line of the text file only contains the item name, the second line of the text file contains only the item type, and the third line of the text file contains the cost, quantity, and tax percentage. No declarations or functions are needed.

b. Sort the structures on the cost data member in DESCENDING order. No declarations, functions, or print routine are needed.

c. Save your structure to the binary file ITEMS.BIN. No declarations or functions are needed.

Step by Step Solution

3.48 Rating (155 Votes )

There are 3 Steps involved in it

Step: 1

Find the source code below I have tested the code so i have provided lines for printing for testing ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Applied Physics

Authors: Dale ewen, Neill schurter, P. erik gundersen

10th Edition

978-0136116332, 136116337, 9780132830096, 978-0132109277

More Books

Students also viewed these Mathematics questions