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
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
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:
- Parenthesis/Brackets: Left -> Right
- Increment/ Decrement: Right -> Left
- Unary: Right -> Left
- Arithmetic: Left -> Right
- Relational: Left -> Right
- Logical: Left -> Right
- Ternary: Right -> Left
- Assignment: Right -> Left
- 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