Computer Science, asked by saisaiteja219, 1 month ago

What is an expression ? WRITE the priority and associativity of different arthimetic operators in C evaluate 2+4*5/2-2/4+2%5​

Answers

Answered by XxkrishnadeewanixX
7

Answer:

What is an expression ? WRITE the priority and associativity of different arthimetic operators in C evaluate 2+4*5/2-2/4+2%5

Answered by remyanairlm
14

Answer:

  • An expression is essentially a sequence or ordering of operators and operands.
  • On evaluating the given expression, 13.5 is the answer.

Explanation:

Expressions can be infix, postfix or prefix.

The priority and associativity of different operators in C are as follows:

  1. Parenthesis/Brackets: Left -> Right
  2. Increment/ Decrement: Right -> Left
  3. Unary: Right -> Left
  4. Arithmetic: Left -> Right
  5. Relational:  Left -> Right
  6. Logical:  Left -> Right
  7. Ternary: Right -> Left
  8. Assignment:  Right -> Left
  9. Comma:  Left -> Right

The expression 2+4*5/2-2/4+2%5​ will be evaluated as:

  • (((2+((4*5)/2))-(2/4))+(2%5))​
  • ((2+(20/2))-0.5)+212-0.5+2

Hence, 13.5 is the answer.

Similar questions