Saltar al contenido

Lesson 73: Constants

English

Give numbers a name

  • A constant is a named value that never changes while the program runs: const int GREEN_PIN = 7;
  • A variable can change: a count, a reading, a score.
  • Constants make a program maintainable: easy for you, or another programmer, to understand and change later.
Feature Why it helps
constants change a value in one place; the name says what it means
meaningful names GREEN_TIME says more than t2
comments explain what each part of the program does
procedures and functions showLight does one job; the program is split into parts

Iniciar sesión o crear cuenta

IGCSE, A-Level & AP