Question
Program in C use -Wall -Werror to compile //This function creates a Node that contains a integer item Node* createNode(int); // This function creates an
Program in C
use -Wall -Werror to compile
//This function creates a Node that contains a integer item Node* createNode(int); // This function creates an empty list pointer and returns it. List* createList ( ); //This function adds an integer item to the end of the list by taking a stack pointer and an integer item to be added and returns the updated stack pointer. In addition, it will print a message matching with the given output. List* pushToStack (List*, int); //This function takes a stack pointer as a parameter and pops off an item from the stack as long as the head and tail are not the same (more than one node in the stack); otherwise, it pops off the remaining node and makes the stack pointer NULL. It also prints a message matching the given output. List* popOffStack (List*); //This function adds an integer item to the beginning of the list by taking a queue pointer and an integer item to be added and returns the updated queue pointer. In addition, it will print a message matching with the given output. List* enQueue (List*, int); //This function takes a queue pointer as a parameter and retrieves an item from the queue as long as the head and tail are not the same (more than one node in the queue); otherwise, it retrieves the remaining node and makes the queue pointer NULL. It also prints a message matching the given output. List* deQueue (List*); main description: 1. Create a linked list ADT based on the given structures in the header file. 2. Generate an array of 5 random integer numbers in a range between 1 and 50. Print out the 'generated' numbers on the console separated by space. 3. Push each of the generated random numbers onto the stack. 4. Print out the newly created stack on the console separated by space in a single line. 5. Pop each of the numbers one by one off the stack until the stack pointer is NULL. 6. Enter each of the previously generated random numbers in the queue. 7. Print out the newly created queue on the console separated by space in a single line. 8. Retrieve each of the numbers one by one from the queue until the queue pointer is NULL. Example output: mwc-070138:~ $ gcc main.c lab6.c -Wall -Werror mwc-070138:~ $ ./a.out Randomly 'generated' numbers: 2 19 42 6 35 Stack: Pushed 2 onto the stack. Pushed 19 onto the stack. Pushed 42 onto the stack. Pushed 6 onto the stack. Pushed 35 onto the stack. The created stack is: 2 19 42 6 35 Popped 35 off the stack. Popped 6 off the stack. Popped 42 off the stack. Popped 19 off the stack. Popped 2 off the stack. The stack is now empty! Queue: Entered 2 in the queue. Entered 19 in the queue. Entered 42 in the queue. Entered 6 in the queue. Entered 35 in the queue. The created queue is: 35 6 42 19 2 Retrieved 2 from the queue. Retrieved 19 from the queue. Retrieved 42 from the queue. Retrieved 6 from the queue. Retrieved 35 from the queue. The queue is now empty!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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