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

Programming Exercises

Write a program to implement a basic stack using an array.

Medium

Problem Statement

Write a program to implement a basic stack using an array.

Sample Input

Push elements 10, 20, 30, then pop an element.

Sample Output

Popped element: 30

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(); bool isEmpty(); }; int main() { // Logic to demonstrate stack operations return 0; }
Log in or sign up to run or submit your code.Log inSign up
Input
Push elements 10, 20, 30, then pop an element.
Expected Output
Popped element: 30