Question: #include /* C99 only */ #define STACK_SIZE 100 /* external variables */ int contents[STACK_SIZE]; int top = 0; void make_empty(void) { top = 0; }
#include /* C99 only */ #define STACK_SIZE 100 /* external variables */ int contents[STACK_SIZE]; int top = 0; void make_empty(void) { top = 0; } bool is_empty(void) { return top == 0; } bool is_full(void) { return top == STACK_SIZE; } void stack_overflow() { printf("stack is full "); } void push(int i) { if (is_full()) stack_overflow(); else contents[top++] = i; } void stack_underflow() { printf("stack is empty "); } int pop(void) { if (is_empty()) stack_underflow(); else return contents[--top]; } int main() {
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
