Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

#define STACK_SIZE 100 #include <stdlib.h> typedef intStackElement; /* External

ID: 3613863 • Letter: #

Question

#define STACK_SIZE 100
#include <stdlib.h>

typedef intStackElement;

/* External Variables:*/
StackElement contents[STACK_SIZE];
int top = -1;

void make_empty(void)
{
top = -1;
}
int is_empty(void)
{
return top == 0;
}
int is_full(void)
{
return top==STACK_SIZE;
}

StackElementstack_top(void)
{
if (is_empty()
      ) stack_underflow();
return contents[top];
}

void pop(void)
{
if (is_empty())
    stack_underflow();
top--;
}
void push(int x)
{
if (is_full())
    stack_overflow();
top++;
contents[top] = x;

}

intstack_underflow(void)
{
printf("Attempted to access an empty stack ");
exit(1);
}

intstack_overflow(void)
{
printf("Attempted push a full stack");
exit(1);
}



Explanation / Answer

please rate - thanks 1 2 3 * + =       gives a7   which is correct, didn't have time to check more #define STACK_SIZE 100 #include #include #include typedef int StackElement; /* External Variables: */ StackElement contents[STACK_SIZE]; int top = -1; void stack_underflow() { printf("Attempted to access an empty stack "); exit(1); } void stack_overflow() { printf("Attempted push a full stack"); exit(1); } void make_empty(void) { top = -1; } int is_empty(void) { return top == -1; } int is_full(void) { return top==STACK_SIZE; } StackElement stack_top(void) { if (is_empty()       ) stack_underflow(); return contents[top]; } int pop(void) { if (is_empty())     stack_underflow(); int x=contents[top]; top--; //for(int i=0;i