ExamYard Lectures

Data types, variables, constants and operators

IGCSE Computer Science 0478 · Chapter 8.1, Programming concepts · 6-minute lecture

The teaching part (1 min) is free to watch. A free account opens the whole lecture: 8 practice questions, 2 real past-paper questions with the answers explained, the mistakes that lose marks, the full-marks tip, a one-card summary and a quick quiz.

What this lecture covers

  1. Boxes with names
  2. Variables and constants
  3. Identifiers
  4. The five data types
Read the transcript of the teaching part

Last time

Before we start: last time, in Finding errors, writing and amending algorithms, you learned these points. Here they are again on one card. Keep them in mind, because today builds on them.

Boxes with names

A program has to remember things: a score, a name, a price. It keeps each one in a named box in memory. A box that can change is a variable. A box that must never change is a constant. Every box also has a type, which says what kind of thing it may hold.

Variables and constants

A variable is a named memory location that stores a value which can change. A constant is a named memory location whose value cannot change while the program runs. A constant is set once, so it can be changed in one place, and cannot be changed by accident. The VAT rate is a good constant, and a running total is a good variable.

Identifiers

An identifier is the name given to a variable, constant, array, procedure or function. It must start with a letter, with no spaces, and it cannot be a keyword like IF or FOR. It should also be meaningful, so TotalCost is better than T.

The five data types

INTEGER holds whole numbers, such as twenty-five, minus three, or zero. REAL holds numbers with a fractional part, such as three point seven five. CHAR holds exactly one character, in single quotes, such as the letter A. STRING holds any run of characters, in double quotes, such as a name or a phone number. BOOLEAN holds only TRUE or FALSE.

How often it comes up

The whole chapter: Test Data.

Chapter 8.1: Programming concepts

Also for IGCSE Computer Science 0478

Which topics come up most in IGCSE Computer Science 0478 past papers, counted from every paper since 2004: Paper 1 topic frequency, Paper 2 topic frequency.

The topical past-paper books: Paper 1, Paper 2.