Menu

[Solved]Lab 6 Linked Lists Stacks Queues Part 1 Model Train Class Exercise Part Create Program Re Q37145572

Lab 6 - Linked Lists, Stacks, and Queues Part 1: Model Train (from in-class exercise) . Part A: Create a program representing

Please need help. Programming in c.

Lab 6 – Linked Lists, Stacks, and Queues Part 1: Model Train (from in-class exercise) . Part A: Create a program representing a model train o Create structs to model a train. You will need: A train struct to represent the whole train that contains a pointer to the first train car A car struct for each train car with: (1) cargo weight (this can be an int) and (2) a pointer to the next car so you can access each car; – . A way to know when you are at the last car weight of each car (Input number may be 0 or 1). (You cannot use malloc to allocate a large array or use stack memory for cars). for your train. o Using scanf to let user input the number of cars in your train and the cargo o You need to use malloc to allocate a separate heap memory space for each car o Print the memory address and cargo weight of each car, then free the memory Show transcribed image text Lab 6 – Linked Lists, Stacks, and Queues Part 1: Model Train (from in-class exercise) . Part A: Create a program representing a model train o Create structs to model a train. You will need: A train struct to represent the whole train that contains a pointer to the first train car A car struct for each train car with: (1) cargo weight (this can be an int) and (2) a pointer to the next car so you can access each car; – . A way to know when you are at the last car weight of each car (Input number may be 0 or 1). (You cannot use malloc to allocate a large array or use stack memory for cars). for your train. o Using scanf to let user input the number of cars in your train and the cargo o You need to use malloc to allocate a separate heap memory space for each car o Print the memory address and cargo weight of each car, then free the memory

Expert Answer


Answer to Lab 6 – Linked Lists, Stacks, and Queues Part 1: Model Train (from in-class exercise) . Part A: Create a program represe… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *