Question Problem 3: Figure 7.13 in the textbook (slide 35 / lesson 07 of the generic slides) shows the two functions pop and push that deal with a stack of characters. Write the program by completing the main function that calls the push function, then prints out the updated stack, then calls the pop function and prints out the updated stack again. #include <stdio.h> #include STACK_EMPTY '0' #include STACK_SIZE 20 void push(char stack(), /* input/output - the stack */ char item, /* input- data being pushed onto the stack */ int *top, /* input/output - pointer to top of stack */ int max size) /* input - maximum size of Stack */ { if (*top < max_size-1) { ++(*top); stack[*top] = item; } char pop (char stack(), /* input/output - the stack */ int *top) /* input/output - pointer to top of stack */ { char item; /* value popped off the stack */ if (*top >= 0) { item = stack[*top]; --(*top); } else { item = STACK_EMPTY; } return (item); } int main (void) { char s [STACK_SIZE]; int stop = -1; // stack is empty /* complete the program here */ return (0); }

OFEDNB The Asker · Computer Science

Transcribed Image Text: Problem 3: Figure 7.13 in the textbook (slide 35 / lesson 07 of the generic slides) shows the two functions pop and push that deal with a stack of characters. Write the program by completing the main function that calls the push function, then prints out the updated stack, then calls the pop function and prints out the updated stack again. #include #include STACK_EMPTY '0' #include STACK_SIZE 20 void push(char stack(), /* input/output - the stack */ char item, /* input- data being pushed onto the stack */ int *top, /* input/output - pointer to top of stack */ int max size) /* input - maximum size of Stack */ { if (*top < max_size-1) { ++(*top); stack[*top] = item; } char pop (char stack(), /* input/output - the stack */ int *top) /* input/output - pointer to top of stack */ { char item; /* value popped off the stack */ if (*top >= 0) { item = stack[*top]; --(*top); } else { item = STACK_EMPTY; } return (item); } int main (void) { char s [STACK_SIZE]; int stop = -1; // stack is empty /* complete the program here */ return (0); }
More
Transcribed Image Text: Problem 3: Figure 7.13 in the textbook (slide 35 / lesson 07 of the generic slides) shows the two functions pop and push that deal with a stack of characters. Write the program by completing the main function that calls the push function, then prints out the updated stack, then calls the pop function and prints out the updated stack again. #include #include STACK_EMPTY '0' #include STACK_SIZE 20 void push(char stack(), /* input/output - the stack */ char item, /* input- data being pushed onto the stack */ int *top, /* input/output - pointer to top of stack */ int max size) /* input - maximum size of Stack */ { if (*top < max_size-1) { ++(*top); stack[*top] = item; } char pop (char stack(), /* input/output - the stack */ int *top) /* input/output - pointer to top of stack */ { char item; /* value popped off the stack */ if (*top >= 0) { item = stack[*top]; --(*top); } else { item = STACK_EMPTY; } return (item); } int main (void) { char s [STACK_SIZE]; int stop = -1; // stack is empty /* complete the program here */ return (0); }
Community Answer
TBLQZZ

C code:- #include &lt;stdio.h&gt; #define STACK_EMPTY 'O' #define STACK_SIZE 20 void push(char stack[],char item, int *top,int max_size){ if (*top &lt; max_size-1) { ++(*top); stack[*top] = item; } } char pop(char stack[], int *top){ char item; if(*top &gt;=0){ item=stack[*top]; --(*top); } else{ item=STACK_EMPTY; } return (item); } void printStack(char stack[], int max_size) { printf("Elements in Stack:n"); for(int i=0;i&lt;STACK_SIZE;i++) { printf("%cn",stack[i]); } } i ... See the full answer