Write a CPP program to implement the STACKS concept.

Use ONLY arrays , functions(methods), loops, if or switch statements .

NO CLASSES , NO Pointers and NO Structures.

The user is to select a choice from a menu to call any of the following functions:

create(s);
push(s,i) <<<== before pushing an item on the stack, make sure that the stack is not full.
Note (items pushed on the stack are ints between 0 and 99)
pop(s,i), <<<= before popping an item off the stack make sure that the stack is not empty
top(s) << == before displaying the top of the STACK make sure that the stack is not empty
purge(s)
check if stack is empty empty(s).

Sample Output

Stack Menu Prompt
Type A to push a number to the stack
Type B to pop a number from the stack
Type C to output the top of the stack
Type D to purge the stack Type E
B
Error underflow, stack is Empty
A
Enter a number between 0 and 99 to push to the stack: 1
Items on the Stack: 1
Stack Menu Prompt
Type A to push a number to the stack
Type B to pop a number from the stack
Type C to output the top of the stack
Type D to purge the stack Type E
A
Enter a number between 0 and 99 to push to the stack: 200
Wrong input try again
Enter a number between 0 and 99 to push to the stack: 20
Items on the Stack: 1 20
Stack Menu Prompt
Type A to push a number to the stack
Type B to pop a number from the stack
Type C to output the top of the stack
Type D to purge the stack Type E
C
Top of the Stack: 20
Stack Menu Prompt
Type A to push a number to the stack
Type B to pop a number from the stack
Type C to output the top of the stack
Type D to purge the stack Type E
B
20 is popped
Items on the Stack: 1
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.