Question: 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

1 Expert Approved Answer
Step: 1 Unlock

Find the source code below I have tested the code so i have provided lines for printing for testing ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!