Here is the C Programming Cheat Sheet - Part 2
2.Expression & Operators Precedence
Following table summarizes the rules for precedence and associativity of all operators, including those that we have not yet discussed. Operators on the same line have the same precedence; rows are in order of decreasing precedence, so, for example, *, /, and % all have the same precedence, which is higher than that of binary + and -. The ``operator'' () refers to function call. The operators -> and . are used to access members of structures;
Description | Operators | Associativity |
---|---|---|
Function Expression | () | Left to Right |
Array Expression | [] | Left to Right |
Structure Operator | -> | Left to Right |
Structure Operator | . | Left to Right |
Unary minus | - | Right to Left |
Increment/Decrement | ++, -- | Right to Left |
Oneโs compliment | ~ | Right to Left |
Negation | ! | Right to Left |
Address of | & | Right to Left |
Value of address | '*' | Right to Left |
Type cast | (type) | Right to Left |
Size in bytes | sizeof | Right to Left |
Multiplication | '*' | Left to Right |
Division | / | Left to Right |
Modulus | % | Left to Right |
Addition | + | Left to Right |
Subtraction | - | Left to Right |
Left Shift | << | Left to Right |
Right Shift | >> | Left to Right |
Less Than | < | Left to Right |
Less Than or Equal to | <+ | Left to Right |
Greater Than | > | Left to Right |
Greater Than or equal | >+ | Left to Right |
Equal to | == | Left to Right |
Not equal to | != | Left to Right |
Bitwise AND | & | Left to Right |
Bitwise exclusive OR | ^ | Left to Right |
Logical AND | && | Left to Right |
Conditional | ?: | Left to Right |
Assignment | =, *=, /=, %=, +=, -=, &=, ^=, =, <<=, >>= | Left to Right |
Comma | , | Right to Left |
Top comments (0)