Question: Develop c++ program to convert infix to postfix and evaluate the postfix expression: 1. Must use stack class with .h and.cpp seperate files 2.Priority =

Develop c++ program to convert infix to postfix and evaluate the postfix expression:

1. Must use stack class with .h and.cpp seperate files

2.Priority =

*, /

+, -

(

psudocode to implement:

Initialize an empty stack (for operators)

While not_finished parsing the expression

{obtain the next input token in the expression;

switch (token)

{case : break; //space

case (: push; break;

case ): pop & display popped element until ( is encountered;

//do not display the (

break;

case +, -, *, /, %: //( and ) are not considered as operators

if empty_stack or priority(token) > priority(stack_top)

push;

else

pop & display popped element until empty_stack or until

priority(token)<=priority(stack_top)

push

break;

case operand: display;

break;

} }

pop & display the rest of the stack elements; //do not display the (

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!