Skip to content

9618 · 10.1

Data Types and Records

Data types are the basic building blocks of programming, like different kinds of Lego bricks. A record is a custom structure you build by combining these different bricks to represent a more complex object.

Need to know

What you need to know

  • **INTEGER**: Whole numbers, e.g., `10`, `-5`, `2024`.
  • **REAL**: Numbers with a decimal part, e.g., `19.99`, `3.14159`, `-0.5`.
  • **CHAR**: A single character, e.g., `'A'`, `'%'`, `'5'`. Note the single quotes.
  • **STRING**: A sequence of characters, e.g., `"Cambridge"`, `"Computer Science 9618"`. Note the double quotes.
  • **BOOLEAN**: Logical values, can only be `TRUE` or `FALSE`.

Explanation

Building with Data Blocks

  1. Identify the individual pieces of data needed to represent a real-world object, like a 'Book'.
  2. For each piece, choose the most suitable basic data type (e.g., String for the title, Integer for the year).
  3. Define a new 'record' type that groups these fields and their chosen data types together under a single name, like 'TBook'.
  4. Declare variables of this new record type to create and manage specific instances, such as 'ThisBook' or an array of books.