Saltar al contenido

Booleanos y selección: if, else, switch

English

True and false in C

  • C has no separate true/false type by default. It uses numbers: 0 means false, and any other number means true.
  • A test like 5 > 3 produces 1 (true). 5 < 3 produces 0 (false).
  • (If you #include <stdbool.h> you can write bool, true, and false — but plain int works everywhere.)

0 counts as false and any other number as true; a comparison gives 1 or 0

Material

Iniciar sesión o crear cuenta

IGCSE, A-Level & AP