Multiple choiceQuestion 1 · Recall
Loading…
By the end you can choose an appropriate data type (INTEGER, REAL, CHAR, STRING, BOOLEAN, DATE, ARRAY or FILE) for a problem, define a record that groups related data of different types, and write pseudocode that reads from and writes to its fields.
A data type tells the computer what kind of value a variable holds, and so what you can do with it. The 9618 pseudocode uses these eight types:
| Type | Description | Example values |
|---|---|---|
| INTEGER | Whole numbers (positive, negative, zero) | 42, -7, 0 |
| REAL | Numbers with a fractional part | 3.14, -0.5, 2.0 |
| CHAR | Exactly one character | 'A', '7', '?' |
| STRING | A sequence of characters | "Hello", "S12345" |
| BOOLEAN | Logical true or false | TRUE, FALSE |
| DATE | A calendar date, written dd/mm/yyyy unless a question says otherwise | 15/03/2008 |
| ARRAY | Many values of the same type under one identifier (you will meet arrays properly in topic 10.2) | DECLARE Scores : ARRAY[1:30] OF INTEGER |
| FILE | The type of a file itself. The program opens the file by its name (a STRING such as "scores.txt"), then reads from or writes to it (you will meet files properly in topic 10.3) |
OPENFILE "scores.txt" FOR READ |
Notice the quotes. Single quotes are for a CHAR, and double quotes are for a STRING, even when the STRING holds only one letter.
Choosing the right type means asking what the data represents:
INTEGERREAL'Y' → CHARSTRINGBOOLEANDATEARRAY, which is a different structure (you will compare it with records below)FILE