Question: Write in C++ Implement a postfix evaluator for logical expressions that use one of these variables: a, b, c, d, e along with operators ^

Write in C++

Implement a postfix evaluator for logical expressions that use one of these variables: a, b, c, d, e along with operators ^ , v, ~ .

Your evaluator allows the user to update variables using an assignment statement e.g. a = true, b = false etc. Initially, all variables are given the value false.

Also, the user may type in a logical expression in postfix form. For example a b v c ^ d e ~ v ^ in infix it really looks like this ((a v b) ^ c) ^ ( d v ~e). Depending on the values of the variables, the program would then output either true or false, according to the rules for each operator. Use a stack of type bool to store the values while processing each given expression. Then you can just push a true or a false onto the stack depending on what the value of the next variable is. You may use an STL stack (#include )... Here is an example of a sample run

a ~ true a = true b = true c = false a b ~ v c ^ false

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!