Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started