Question: PLEASE HELP with this C program, must compile in GNU compiler Please use an array for the stacks. Any help is much appreaciated THANK YOU!

 PLEASE HELP with this C program, must compile in GNU compilerPlease use an array for the stacks. Any help is much appreaciated

PLEASE HELP with this C program, must compile in GNU compiler

Please use an array for the stacks. Any help is much appreaciated THANK YOU!

Write a program that implements a stack. The stack will have 5 int slots. It will use pointer arithmetic for everything I DO NOT want to see an index, or variable that keeps track of the current element, except the top pointer (which points to the stack), ANYWHERE in your programs (I will count off HEAVILY). This program should 1. Have a function called push(pass in top) that requests an int value from the user and puts it on the stack. 2. Have a function called pop(pass in top) that takes a number off the stack and prints it out to the user. 3. When a user chooses to exit the program, call a function named unwind(pass in top), that pops everything left on the stack by calling pop until the stack is empty. 4. You will need an int pointer called top (local!!) that keeps track of the last element inserted into the stack. You will need to test top for the lower limit (address) of the stack when you pop (you also need to test for the upper limit of the stack, before pushing) 5. The functions will be passed top. Depending on how you implement this, you might need to return top. THIS IS THE TRICKY PART (there are notes on Canvas). 6. Call the functions from main. last assignment If you are having trouble with the assignment - do this last! Don't let this keep you from getting the assignment done! 7. menu: exit (unwinds stack and terminates) push value onto stack pop value off stack 1 2 I NEED for you use the SAME menu values as above, so that I can use a data file to run the programs. If you ask for "extra" things, my file will not work. if the user inputs 1, then program will ask for an integer to push, unless the stack is full If user inputs 2, the program will print the value off the top. If user inputs O, the program exits If the user inputs a menu option that is not listed, the program will print an error message which includes the invalid option's value and prints the menu again (don't exit, just tell them it was not valid) Write a program that implements a stack. The stack will have 5 int slots. It will use pointer arithmetic for everything I DO NOT want to see an index, or variable that keeps track of the current element, except the top pointer (which points to the stack), ANYWHERE in your programs (I will count off HEAVILY). This program should 1. Have a function called push(pass in top) that requests an int value from the user and puts it on the stack. 2. Have a function called pop(pass in top) that takes a number off the stack and prints it out to the user. 3. When a user chooses to exit the program, call a function named unwind(pass in top), that pops everything left on the stack by calling pop until the stack is empty. 4. You will need an int pointer called top (local!!) that keeps track of the last element inserted into the stack. You will need to test top for the lower limit (address) of the stack when you pop (you also need to test for the upper limit of the stack, before pushing) 5. The functions will be passed top. Depending on how you implement this, you might need to return top. THIS IS THE TRICKY PART (there are notes on Canvas). 6. Call the functions from main. last assignment If you are having trouble with the assignment - do this last! Don't let this keep you from getting the assignment done! 7. menu: exit (unwinds stack and terminates) push value onto stack pop value off stack 1 2 I NEED for you use the SAME menu values as above, so that I can use a data file to run the programs. If you ask for "extra" things, my file will not work. if the user inputs 1, then program will ask for an integer to push, unless the stack is full If user inputs 2, the program will print the value off the top. If user inputs O, the program exits If the user inputs a menu option that is not listed, the program will print an error message which includes the invalid option's value and prints the menu again (don't exit, just tell them it was not valid)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!