Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

OPERATOR hierarchy () first priority ** second priority *, / third priority +, - last priority I want a c basic code that calculates according

image text in transcribed

OPERATOR hierarchy

() first priority

** second priority

*, / third priority

+, - last priority

I want a c basic code that calculates according to process priority using the above features

for example 3*5+2 first of all 3*5 must be solve after that +2

another example

(2+2)*3 primarily in parentheses after others.

I wrote on top, must use stack,POP.

Algorithm for Evaluation of Postfix Expression Create an empty stack and start scanning the postfix expression from left to right. If the element is an operand, push it into the stack. If the element is an operator o, pop twice and get A and B respectively. Calculate BOA and push it back to the stack. When the expression is ended, the value in the stack is the final answer. Evaluation of a postfix expression using a stack is explained in below example: 2 10 + 9 6 - 1 push 2 push 10 pop 10 pop 2 push 9 push 6 pop 6 pop 9 Pop 3 pop 12 pop answer: 4 push 2 + 10 = 12 push 9 - 6 = 3 push 12 / 3 = 4 6 10 9 3 3 2 12 12 12 4 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 24th International Conference Dexa 2013 Prague Czech Republic August 2013 Proceedings Part 1 Lncs 8055

Authors: Hendrik Decker ,Lenka Lhotska ,Sebastian Link ,Josef Basl ,A Min Tjoa

2013 Edition

3642402844, 978-3642402845

More Books

Students also viewed these Databases questions

Question

5. Discuss the key components of behavior modeling training.

Answered: 1 week ago