← Computer Science

Data Types, Variables and Constants

Every value a program stores has a data type, and choosing the right one keeps your code correct and efficient. In this lesson we meet the five basic data types, learn the difference between a variable and a constant, and practise declaring and assigning values using Cambridge pseudocode.

Slide 1 / 4

The five basic data types

Data typeExampleINTEGER7 (a whole number)REAL3.14 (has a decimal)CHAR'A' (one character)STRING"Hello" (a run of text)BOOLEANTRUE (or FALSE)
  • An INTEGER is a whole number with no fractional part, such as 7, 0 or -42, and is used for things you count like scores or ages.
  • A REAL is a number that can have a fractional part, such as 3.14 or 19.99, and is used for measurements, prices and averages.
  • A CHAR holds exactly one single character, such as the letter 'A' or the symbol '?', and is written in single quotes.
  • A STRING holds a sequence of zero or more characters, such as "Hello" or a pupil's name, and is written in double quotes.

Check you've got it

0/4

1. A program needs to store the price of an item in pounds and pence, for example 4.99. Which data type is the most suitable?

2. Which statement about a constant in Cambridge pseudocode is correct?

3. Which line correctly assigns the value zero to a variable called Total in Cambridge pseudocode?

4. Consider the code: DECLARE Grade : CHAR followed by Grade <- 'B'. Which value has been stored and why is it valid?

Practise real exam questions on this

Type your answer, see your mark against the mark scheme in seconds. Free, 5 a day.

Start practising →

Teaching this topic?

Mark your whole class's answers and see who's stuck, for £19 a month.

See the class plan →

Free revision content. Multiple-choice answers are marked instantly. Written answers are marked by AI on /free-mark.