← C Programming learning path
C Programming · Module 3 of 10

Operators and decisions

Calculate with operators and choose paths with if, else and switch.

📖 Key ideas

  1. Arithmetic: + - * / %; comparison: == != < > <= >=.
  2. Logical: && (and), || (or), ! (not).
  3. if/else if/else choose a path.
  4. switch matches a value against cases; use break in each case.
  5. In C, 0 is false and any non-zero value is true.
💡 Real-life example: switch is a lift panel: press 3 and it goes straight to floor 3 instead of checking every floor.
%Remainder operator
&&Logical AND
switchChooses a case by value
breakLeaves the switch