Precedence revisited
Upon hearing me complain about the complexity of remembering operator precedence during one of my seminars, a student suggested a mnemonic that is simultaneously a commentary: “Ulcer Addicts Really Like C A lot.”
Mnemonic
|
Operator type
|
Operators
|
Ulcer
|
Unary
|
+ - ++--
|
Addicts
|
Arithmetic (and shift)
|
* / % + - << >>
|
Really
|
Relational
|
> < >= <= == !=
|
Like
|
Logical (and bitwise)
|
&& || & | ^
|
C
|
Conditional (ternary)
|
A > B ? X : Y
|
A Lot
|
Assignment
|
= (and compound assignment like *=)
|
Of course, with the shift and bitwise operators distributed around the table it is not a perfect mnemonic, but for non-bit operations it works.