C- Language Operator Precedence and Associativity |
Precedence and Associativity in C Language
Priority | Operator | Associativity |
---|---|---|
1 | [ ] (Subscript), ( ) (Bracket operator) |
Left to Right (L → R) |
2 | . (Dot operator), -> (Arrow membership) |
Left to Right (L → R) |
3 |
Unary operators (+, -, ++, --, ~, sizeof(), typecast), Address of (&), Value at |
Right to Left (R → L) |
4 | Arithmetic (*, /, %) | Left to Right (L → R) |
5 | Arithmetic (+, -) | Left to Right (L → R) |
6 | Shift operators (<< Left Shift, >> Right Shift) | Left to Right (L → R) |
7 | Relational operators (<, <=, >, >=) | Left to Right (L → R) |
8 | Equality operators (==, !=) | Left to Right (L → R) |
9 | Bitwise AND (&) | Left to Right (L → R) |
10 | Bitwise XOR (^) | Left to Right (L → R) |
11 | Bitwise OR (|) | Left to Right (L → R) |
12 | Logical AND (&&) | Left to Right (L → R) |
13 | Logical OR (||) | Left to Right (L → R) |
14 | Conditional operator (?:) | Right to Left (R → L) |
15 | Assignment operators (=, +=, -=, *=, /=, %=) | Right to Left (R → L) |
16 | Comma operator (,) | Left to Right (L → R) |