Stack Operations (Exercise)


After observing the code in this post (Stacks) , implement a stack with a maximum size of 5 elements using flowgorithm.

The program must continuously prompt the user for an option:

push -if the user enters push, prompt the user to enter an integer and push it onto the stack
pop -if the user enters pop, display the integer at the top of the stack and remove it
peek – If the user enters peek, display the integer at the top of the stack
exit – exits the program.

Ensure that the program works in all cases, e.g if the stack is full and and the user tries pushing another element, display an appropriate error message.

Updates to this post

2023-09-14 – Fixed broken link to stack code

© 2020  Vedesh Kungebeharry. All rights reserved. 

One thought on “Stack Operations (Exercise)

Leave a comment