#include
#include
#define MAX 50
#define EMPTY -1
struct stack
{
int data[MAX];
int top;
};
int isempty(struct stack *s)
{
return (s->top == EMPTY) ? 1 : 0;
}
void emptystack(struct stack* s)
{
s->top = EMPTY;
}
void push(struct stack* s,int item)
{
if(s->top == (MAX-1))
{
printf(“nSTACK FULL”);
}
else
{
++s->top;
s->data[s->top]=item;
}
}
int pop(struct stack* s)
{
int ret=EMPTY;
if(s->top == EMPTY)
printf(“nSTACK EMPTY”);
else
{
ret= s->data[s->top];
–s->top;
}
return ret;
}
void display(struct stack s)
{
while(s.top != EMPTY)
{
printf(“n%d”,s.data[s.top]);
s.top–;
}
}
int isoperator(char e)
{
if(e == ‘+’ || e == ‘-‘ || e == ‘*’ || e == ‘/’ || e == ‘%’)
return 1;
else
return 0;
}
int priority(char e)
{
int pri = 0;
if(e == ‘*’ || e == ‘/’ || e ==’%’)
pri = 2;
else
{
if(e == ‘+’ || e == ‘-‘)
pri = 1;
}
return pri;
}
int evaluate(char *postfix)
{
char *p;
struct stack stk;
int op1,op2,result;
emptystack(&stk);
p = &postfix[0];
while(*p != ‘