By Dan Gookin

Part of Beginning C Programming For Dummies Cheat Sheet

The order of precedence determines which operators act upon a value first. When crafting statements, know the order of precedence to ensure that the program does what you intend.

Operator(s) Category Description
! Unary Logical not; associativity goes right to left
++ — Unary Increment, decrement, read from right to left
* / % Math Multiplication, division, modulo
+ – Math Addition, subtraction
<< >> Binary Shift left, shift right
< > <= >= Comparison Less than, greater than, less than or equal to, greater than or
equal to
== != Comparison Is equal to, not equal to
& Binary And
^ Binary Exclusive or (XOR)
| Binary Or
&& Logical And
|| Logical Or
?: Comparison Weird if thing; associativity goes right to left
= Assignment Variable assignment operator, including the +=, *=, and all
assignment operators
, (None) The comma separates items in a for
statement; precedence from left to right

The order of precedence can be overridden by using parentheses. Simply enclose within a set of parentheses the part of the equation that you want executed first. That part is executed first no matter what the priority is.