Write a program to implement a basic stack using an array.
MediumProblem 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;
}
Input
Push elements 10, 20, 30, then pop an element.
Expected Output
Popped element: 30