
Step 2 - If it is EMPTY, then display "Stack is EMPTY!!! Deletion is not possible!!!" and terminate the function.Step 1 - Check whether stack is EMPTY.We can use the following steps to pop an element from the stack. Pop function does not take any value as parameter. In a stack, the element is always deleted from top position. In a stack, pop() is a function used to delete an element from the stack. Step 3 - If it is NOT FULL, then increment top value by one ( top++) and set stack to value ( stack = value).Step 2 - If it is FULL, then display "Stack is FULL!!! Insertion is not possible!!!" and terminate the function.We can use the following steps to push an element on to the stack. Push function takes one integer value as parameter and inserts that value into the stack. In a stack, the new element is always inserted at top position. In a stack, push() is a function used to insert an element into the stack. Push(value) - Inserting value into the stack Step 5 - In main method, display menu with list of operations and make suitable function calls to perform operation selected by the user on the stack.Step 4 - Define a integer variable 'top' and initialize with '-1'.Step 3 - Create a one dimensional array with fixed size ( int stack).Step 2 - Declare all the functions used in stack implementation.Step 1 - Include all the header files which are used in the program and define a constant 'SIZE' with specific value.Stack Operations using ArrayĪ stack can be implemented using array as follows.īefore implementing actual operations, first follow the below steps to create an empty stack.

Whenever we want to delete a value from the stack, then delete the top value and decrement the top value by one. Whenever we want to insert a value into the stack, increment the top value by one and then insert.

Just define a one dimensional array of specific size and insert or delete the values into that array by using LIFO principle with the help of a variable called 'top'. But stack implemented using array stores only a fixed number of data values. A stack data structure can be implemented using a one-dimensional array.
