Skip to content
UPEEC

Operators in C

Arithmetic, relational, logical, bitwise, assignment and the ternary operator.

Beginner
Comments 0

C has all the usual arithmetic and comparison operators plus:

  • Logical: &&, ||, ! — short-circuit evaluation.
  • Bitwise: & | ^ ~ << >> — essential for hardware registers.
  • Increment/decrement: i++, ++i.
  • Ternary: max = (a > b) ? a : b;

A classic bug is writing if (x = 5) (assignment, always true) instead of if (x == 5).

Sub-topics (1)

Bitwise Operators

Operate on individual bits: AND, OR, XOR, NOT and shifts — the language of hardware registers.

Easy♥ 0🔖 0💬 0

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.