My issue
// Remove the __ and complete the code
define MAX_SIZE 101
int a[MAX_SIZE];
int top = -1;
void push(int ele) {
if (top <= MAX_SIZE - 1) {
a[__] = __;
printf(“Pushed: %d\n”, __);
} else {
printf(“Stack is full. Cannot push: %d\n”, ele);
}
}
int pop() {
if (top >= 0) {
int ele = a[__];
top–;
printf(“Popped: %d\n”, ele);
return __;
} else {
printf(“Stack is empty. Cannot pop.\n”);
return -1;
}
}
My code
// Remove the __ and complete the code
#define MAX_SIZE 101
int a[MAX_SIZE];
int top = -1;
void push(int ele) {
if (top <= MAX_SIZE - 1) {
a[__] = __;
printf("Pushed: %d\n", __);
} else {
printf("Stack is full. Cannot push: %d\n", ele);
}
}
int pop() {
if (top >= 0) {
int ele = a[__];
top--;
printf("Popped: %d\n", ele);
return __;
} else {
printf("Stack is empty. Cannot pop.\n");
return -1;
}
}
Learning course: Data Structures & Algorithms using C
Problem Link: Push and Pop in Data Structures & Algorithms using C