Write pseudocode statements for: the declaration and initialisation of constants

Published by Patrick Mutisya · 14 days ago

Cambridge A-Level Computer Science – 11.1 Programming Basics

11.1 Programming Basics – Declaration and Initialisation of Constants

Learning Objective

Write pseudocode statements for the declaration and initialisation of constants.

Key Concepts

  • Constant: A named value that cannot be altered after it is set.
  • Identifier: The name given to a constant; must follow the language’s naming rules.
  • Initialisation: Assigning a value to a constant at the point of declaration.
  • Scope: The region of the program where the constant can be accessed.

Pseudocode Syntax for Constants

In the Cambridge A‑Level pseudocode, a constant is declared with the CONST keyword followed by the identifier, an optional type, and the value it is to hold.

Constant NameType (optional)ValuePseudocode Statement
MAX_STUDENTSINTEGER30CONST MAX_STUDENTS : INTEGER ← 30
PIREAL3.14159CONST PI : REAL ← 3.14159
WELCOME_MSGSTRING"Welcome to the system"CONST WELCOME_MSG : STRING ← "Welcome to the system"
GRA \cdot ITYREAL9.81CONST GRA \cdot ITY : REAL ← 9.81

Examples in Context

  1. Declare a constant for the number of days in a week:

    CONST DAYSINWEEK : INTEGER ← 7

  2. Declare a constant for the tax rate used throughout a financial program:

    CONST TAX_RATE : REAL ← 0.20

  3. Use a constant in an expression:

    To calculate the circumference of a circle, you might write:

    CONST PI : REAL ← 3.14159

    circumference ← 2 * PI * radius

    where the value of PI cannot be changed later in the program.

Mathematical Representation

The value of a constant can be shown mathematically, for example the constant π:

\$\pi = 3.14159\$

Suggested Diagram

Suggested diagram: A flowchart showing where constants are declared (typically at the start of the program) and how they are used in later calculations.