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.

© 2020  Vedesh Kungebeharry. All rights reserved. 

One thought on “Stack Operations (Exercise)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s