Question: *** I need this program finished. It a simple stack program which has a menu that gives the user the option to create a stack,

*** I need this program finished. It a simple stack program which has a menu that gives the user the option to create a stack, Push an item like a number in the stack, pop an item in the stack, Check the top of the stack ,purge the stack, and end the program. After the user selects what he wants to do it returns to the menu after the operation is complete so that he can choose what he wants to do next. Also must make sure an error message is displayed if a user attempts to pop an empty stack etc. IN C++

1- Create a stack

2- Push an item in the stack

3- Pop an item in the stack

4- Check the top of the stack

5- Purge the stack

6- End program

#include #include using namespace std;

struct inforec{ int number; }

struct Stack{ inforec i[SIZE] int top; };

Stack s;

int main ()

{ // Creates a Stack void crea_stack(stack & s) { s.top = -1; count = 0; }

// Checks to see if Stack is empty int empty(constant Stack & s) { return (s.top == -1); }

// Pushes an item on the stack void push(stack & s, CONST inforec & i) { ++ s.top; s.i[s.top]= i; }

// Pops an item on the stack void pop(stack & s, inforec & item) { item = s.i[s.top --]; }

// Checks the top of the stack int Top_item(constant stack & s) { return(s.top); }

}

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!