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
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
Find the source code below I have tested the code so i have provided lines for printing for testing ... View full answer
Get step-by-step solutions from verified subject matter experts
