Algorithm for implementing Queue using stack
- While stack1 is not empty, push everything from stack1 to stack2.
- Push value to stack1.
- Push everything back to stack1.
- In this function first we will check if the queue has some element or not.
- If our queue is empty then we cannot delete any element from it.
- Else if there element in the queue we will pop an element from the top of stack1.
- Initialize a for loop from zero till the top.
- Print the element at every successful iteration.
- In this way we can display our queue.