Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a program to reverse a string using a stack data structure.

Hard

Problem Statement

Write a program to reverse a string using a stack data structure.

Sample Input

std::string str = "Hello";

Sample Output

Reversed string: olleH

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
#include <iostream> #include <stack> void reverseString(std::string str); int main() { // Logic to demonstrate string reversal return 0; }
Log in or sign up to run or submit your code.Log inSign up
Input
std::string str = "Hello";
Expected Output
Reversed string: olleH