#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);
}