GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.geeksforgeeks.org — C++ Program to Reverse a String Using Stack - GeeksforGeeks C++ Program to Reverse a String Using StackLast Updated : 22 Aug, 2026 Reversing a string using a stack means pushing all characters onto the stack and then popping them one by one. Since a stack follows the Last In, First Out (LIFO) principle, the characters are retrieved in reverse order.
Examples:
ApproachThe approach follows these steps:
Output Reversed string is ziuQskeeG Explanation: The string "GeeksQuiz" is pushed into the stack from left to right. The last character, 'z', is pushed last and therefore popped first. Similarly, the remaining characters are popped in reverse order and placed back into the string. Thus, the original string:
becomes:
and the final result is:
Try It Yourself Comment ExploreStandard Template Library(STL) Practice & Problems |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |