See explaination

Explanation:

#include<iostream>

#include<stdlib.h>

#include<string.h>

#include<math.h>

using namespace std;

const int MAX = 100;

//stack structure

struct stack{

string st;

int top = -1;

//push an item to the stack

void push(char x)

{

if(top==MAX-1){

cout << "Stack overflow\n";

return;

}

st[++top] = x;

}

//delete the topmost element

char pop()

{

if(top==-1){

cout << "Stack underflow\n";

return 0;

}

return st[top--];

}

//return topmost element

char peek()

{

return st[top];

}

};

//function prototypes

int precedence(char x);

string convert(string infixExpression);

int evaluate(string postFix);

//main function

int main()

{

string infix, postfix;

do{

//prompt and read infix expression

cout<< "Enter expression (or exit to end):" <<endl;

getline(cin, infix);

if(infix=="exit") break;

if(infix[0]=='(' || isdigit(infix[0]))

{

cout << "Expression: " << infix << endl;

string postfix = convert(infix);

cout << "Postfix form: " << postfix <<endl;

int result = evaluate(postfix);

cout << "Result:" << result << endl;

}

else

cout << "Invalid expression" <<endl;

}while(1);

return 0;

}

//function to return precedence

int precedence(char x)

{

switch(x)

{

case '(':

return 0;

case '+':

case '-':

return 1;

case '*':

case '/':

return 2;

case '^':

return 3;

default : return 999;

}

}

//function to convert from infix to postfix expression

string convert(string infix)

{

stack stk;

string postfix = "";

stk.push('(');

int count = 0;

for(int i=0; i<infix.size(); i++)

{

if(isalpha(infix[i]))

count++;

}

infix = infix + ")";

for(int i=0; i<infix.size(); i++)

{

char ch = infix[i];

if(ch==' ') continue;

if(isalpha(ch))

{

postfix = postfix + " " + ch;

}

else if(ch=='(')

{

stk.push('(');

}

else if(ch==')')

{

while(stk.peek()!='(')

{

postfix = postfix + " " + stk.pop();

}

stk.pop();

}

else

{

int p1 = precedence(ch);

int p2 = precedence(stk.peek());

while(p1<=p2)

{

postfix = postfix + " " + stk.pop();

p2=precedence(stk.peek());

}

stk.push(ch);

}

}

return postfix;

}

//function to evaluate postfix expression

int evaluate(string postFix)

{

stack stk;

for(int i=0; i<postFix.size(); i++)

{

char c = postFix[i];

if(c==' ') continue;

if(isdigit(c))

{

int val = c - '0';

stk.push(val);

}

else

{

int x = stk.pop();

int y = stk.pop();

switch(c)

{

case '+':

stk.push(y+x);

break;

case '-':

stk.push(y-x);

break;

case '*':

stk.push(y*x);

break;

case '/':

stk.push(y/x);

break;

case '^':

stk.push(pow(y,x));

break;

}

}

}

return stk.pop();

}

Here, It would be: - (-7 + 3)

= 7 - 3 = 4

In short, Your Answer would be 4

Hope this helps!

= 7 - 3 = 4

In short, Your Answer would be 4

Hope this helps!

You just change the sign of each value so - 7 becomes 7 and +3 becomes - 3 so the answer is

+7-3

= 7-3

=4

+7-3

= 7-3

=4

step-by-step explanation: left be aligning the decimal points is required to not required see the number of digits to the right...Read More

1 more answers

answer: 414,377,008step-by-step explanation: just multiply it...Read More

3 more answers

honestly bro aint no one got time to answer these dumb question just do it p***ystep-by-step explanation:...Read More

1 more answers

Explanation:The closer the value of r is to 1 or -1, the stronger the relationship between the two variables plotted on the graph either positive or negative. Where 1 or -1 means t...Read More

3 more answers

can you complete your sentence? i could !...Read More

1 more answers

- can some smart please help me on this question if you don’t know pleas...
- What is equivalent to 5/4?...
- In the expression 8 × ( 13 − 8 ) ÷ 4 + 5 , what is the first computati...
- A chef uses the expression 0.3n to represent the pounds of beef to use...
- If c=42+ d is true, then which is greater cord or are you not able to...
- What will be the coordinates of parallelogram ABCD after a dilation ab...
- In 1985, there were 852 cell phone subscribers in the small town of Ce...
- Evaluate the expression: z(x + 3y) when x = 6, y = 8, and z = 5...
- Chris loves going to Chuck E. Cheese. Each time he goes he gets a pizz...
- What is the area 38cm 16cm 20cm 18cm...