Create a class to manage a simple stack using an array with methods for push and pop.
HardProblem 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;
}
Input
Stack s; s.push(5); s.push(10);
Expected Output
Popped element: 10