student@ubuntu:~$
c 2/5 25 XP

C Operators

0%

Quick Reference

Operator precedence (high to low):

Precedence Operators Notes
Highest () [] -> . Grouping, access
Unary ! ~ ++ -- * & (type) Right-to-left
Arithmetic * / % then + - Left-to-right
Comparison < <= > >= then == !=  
Bitwise & ^ \|  
Logical && then \|\| Short-circuit
Ternary ? : Right-to-left
Assignment = += -= etc. Right-to-left

Common Pitfalls

  • = vs ==if (x = 5) assigns 5 to x (always true). Use if (x == 5) to compare.
  • & vs &&& is bitwise AND. && is logical AND. Mixing them up causes subtle bugs.
  • Integer division5 / 2 is 2, not 2.5. Cast one operand: (double) 5 / 2.
  • Truncation on cast(int) 3.99 is 3, not 4. Casting truncates, it does not round.

Unlocks

Complete this skill to see what it unlocks.