Hey guys, I need to write a code to evaluate postfix expression. I started on it but now I'm stuck. Below I have what I started on and the file that it needs to go into. I need it to do the following:
If the token is an operator of two items are popped off the stack. the operator is applied to them
the result is pushed back onto the stack
So far I have
for (i=0; i < token; i++)
if (token[i] == integer)
{
Push(token[i];
}
else if (token[i] == '*; || token[i] == '+'|| token[i] == '/' || token[i] == '-')
{
stack = pop();
stack2 = pop();
switch(token[i])
{
case '+' : q= stack2 + stack break;
case '-' : q= stack2 - stack break;
case '*' : q= stack2 * stack break;
case '/' : q= stack2 / stack break;
}
Push (q);
z = Pop();
return z