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
Step: 1
Find the source code below I have tested the code so i have provided lines for printing for testing ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started