Objective: Given a stack, write a program to print the stack elements in reverse order.

Example:

Approach:

Use Temporary stack:

Take temporary stack, and copy all the items from the given stack to a temporary stack. Elements will be stored in a temporary stack in reverse order. Now print elements from the temporary stack and while printing, restore all the elements to the originally given array.