Write a program that stores information about the products in a single linked list that is being sold in a store: product code, product name and price.
In the second single linked list stores data on products purchased by individual customers. Each of the element of the second list represents one item of an account and contains the following elements: ordinal
bill number, quantity and pointer to the corresponding product in the first list (each element of the second lists, in addition to containing a pointer to the next element, also contains a pointer to one of elements in the first list). The lists are not sorted. Data is entered as long as the user wants it.

The structures required for implementation are:

> struct product
> {
> int code;
> char title[51];
> float price;
> product*sequence;
> };
> struct item
> {
> long br;
> int amount;
> product *info;
> item*sequence;
> 

};

Write a function that will print all the bill codes for the given product we want to check the total quantity purchased of that product. The function is called until the user decides to end interaction with the program.

So, basically I'm begginer and I got this assignement that I must do. I'm struggling to make it done, but it is for some reason hard to grasp for me.
Anyone who has a tip and wants to share it with me is more than welcome.
Thank you, and have a nice day y'all!

Dani AI

Generated

— break the task into small, testable steps (exactly what suggested). Treat the problem as: (1) identify the product to query (by its unique code), (2) scan the entire purchase-list once, (3) when a purchase entry references that product, record the bill number and add the quantity to a running total. Keep the implementation simple and defensive: verify pointers before dereferencing and confirm the product exists before scanning purchases.

Handle duplicates and edge cases explicitly. If a single bill can contain multiple lines for the same product, collect bill numbers into a set to avoid printing one bill multiple times while still summing all quantities. Prefer comparing product identity by its unique code rather than raw pointer equality unless it is guaranteed every purchase node points to the exact product node in memory. Use a wide integer type for bill IDs and an integer type for quantities; treat money with care (double is generally safer than float for totals). Complexity is linear in the number of purchase items; if users will query many different products, build a simple index (hash map from product code to a list of purchase pointers) to speed repeated queries.

Troubleshooting tips: test with zero, one and many matching purchases; deliberately insert duplicate bill lines to confirm the set logic; check for null pointers after input loops. For deduplication utilities, see std::unordered_set.

When I have a big job (I haven't had school assignments for decades) my approaches are:

  1. Design first, code later.
  2. If the design is overwhelming then I break the design into manageable components.
  3. If a component or chunk is still too big I break it down further.

Sometimes those new to this work try to code without the design or break it up into manageable pieces steps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.