Correct option is A
In C, the order of precedence of operators from lowest to highest is as follows:
1. Logical AND (&&): Has the lowest precedence among the options listed.
2. Addition (+): Has a higher precedence than logical AND but lower than multiplication and parentheses.
3. Multiplication (*): Has a higher precedence than addition and logical AND, but lower than parentheses.
4. Parentheses (()): Has the highest precedence, as they are used to explicitly specify the order of operations.
Important Key Points:
1. Operator Precedence: Determines the order in which operators are evaluated in an expression.
2. Parentheses: Can override default precedence by explicitly specifying the order of operations.
3. Associativity: When operators have the same precedence, associativity determines the order of evaluation. For most operators, associativity is left to right. However, for assignment operators and the conditional operator (?:), it is right to left.
Knowledge Booster:
1. Understanding Precedence: Knowing the precedence of operators helps in writing expressions that are evaluated correctly without unexpected results.
2. Using Parentheses: To ensure the correct order of operations, use parentheses even when operator precedence might make it unnecessary. It enhances code readability.
3. Examples:
· Without Parentheses: 3 + 4 * 5 evaluates to 3 + (4 * 5) = 23.
· With Parentheses: (3 + 4) * 5 evaluates to 7 * 5 = 35.