Document 3
Document 3
#define MAX 5
if (top == MAX - 1)
else {
stack[++top] = val;
cout << "Pushed " << val << " to stack." << endl;
void pop() {
if (top == -1)
else
cout << "Popped " << stack[top--] << " from stack." << endl;
void display() {
if (top == -1)
else {
int main() {
do {
cout << "\n1) Push\n2) Pop\n3) Display\n4) Exit\nEnter your choice: ";
switch (choice) {
case 1:
push(val);
break;
case 2:
pop();
break;
case 3:
display();
break;
case 4:
break;
default:
}
} while (choice != 4);
return 0;