Question: Complete the following program to evaluate an integer expression with + , - , *,/operations in prefix notation, where operands and operators are separated by
Complete the following program to evaluate an integer expression with + , - , *,/operations in prefix notation, where operands and operators are separated by single or multiple spaces, and the expression is stored in a character buffer. Compile, debug and run your program. // prefix.epp # include #include #include #include struct stack { // stack class int data[64]: int top: stack(){top = -l;} void push(int x){data(++top] = x;} int pop() {return data [top--];} int main() { char b[80]: //character buffer stack s: //stack object int length: //length of string // ask user to type an integer expression in prefix notation printf("Type an integer expression in prefix notation: "): gets(b): length = strlen(b): // evaluate the prefix notation here // print the notation and the evaluation result printf("%s = %d ", b, s.pop()): return 0: } Use the above program prefix.epp as an example and write a program named postfix.epp to evaluate an integer expression with +, - , *,/operations in postfix notation. Compile, debug, and run your program
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
