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

Programming Exercises

Create a class to manage a simple stack using an array with methods for push and pop.

Hard

Problem Statement

Create a class to manage a simple stack using an array with methods for push and pop.

Sample Input

Stack s; s.push(5); s.push(10);

Sample Output

Popped element: 10

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
#include <iostream> #define MAX 100 class Stack { private: int arr[MAX]; int top; public: Stack(); void push(int x); int pop(); }; int main() { // Logic to demonstrate Stack functionality return 0; }
Log in or sign up to run or submit your code.Log inSign up
Input
Stack s; s.push(5); s.push(10);
Expected Output
Popped element: 10