C operator precedence and associativity pdf




















Function call or brace. Array subscription. Member access struct and union. Pointer member access struct and union. Left to right. Logical NOT. Binary plus. Returns size of data or type. Right to left. Modular division. Binary minus. Left shift. Right shift.

Less than. Greater than. If we wish to evaluate 5 - 17 first, then we must enclose them within parentheses :. The following table taken from cppreference.

Precedence Level 1 signifies operators of highest priority, while Precedence Level 17 signifies operators of the lowest priority. Operator associativity is the direction from which an expression is evaluated.

For example,. Hence, the value of b is assigned to a , and not in the other direction. Also, multiple operators can have the same level of precedence as we can see from the above table. When multiple operators of the same precedence level are used in an expression, they are evaluated according to their associativity. Reinterpreted type conversion. Static type conversion. Size of object or type. Prefix increment. Prefix decrement. One's complement. Logical not.

Unary negation. Unary plus. Pointer-to-member objects or pointers. Left shift. Right shift. Less than. Greater than. Less than or equal to. Greater than or equal to. Bitwise exclusive OR. Bitwise inclusive OR.



0コメント

  • 1000 / 1000