Cambridge 9618 requires knowledge of five fundamental data types. Every variable must be declared with one of these types using the DECLARE keyword:
Whole numbers, positive or negative. No decimal point.
e.g., 0, -5, 42, 1000
Numbers with a decimal point (floating-point).
e.g., 3.14, -0.5, 2.0, 9.81
A single character. Enclosed in single quotes.
e.g., 'A', '5', '!', ' '
A sequence of characters. Enclosed in double quotes.
e.g., "Hello", "9618", "", "AB12"
Only two possible values: TRUE or FALSE.
Used for conditions and flags.
A constant is a named storage location whose value does not change during program execution. Cambridge 9618 uses the CONSTANT keyword:
Note: constants use = not ← in their declaration. They cannot be changed later in the program.
PI * radius * radius is clearer than 3.14159 * radius * radiusCambridge 9618 provides built-in functions for converting between data types:
| Function | Converts | Example | Result |
|---|---|---|---|
INT(x) | REAL → INTEGER (truncates) | INT(3.7) | 3 |
REAL(x) | INTEGER → REAL | REAL(5) | 5.0 |
STRING(x) | Any → STRING | STRING(42) | "42" |
INT(x) | STRING → INTEGER | INT("25") | 25 |
REAL(x) | STRING → REAL | REAL("3.14") | 3.14 |
CHR(n) | INTEGER → CHAR (ASCII) | CHR(65) | 'A' |
ASC(c) | CHAR → INTEGER (ASCII code) | ASC('A') | 65 |
Cambridge 9618 provides built-in string functions:
| Function | Purpose | Example | Result |
|---|---|---|---|
LENGTH(s) | Number of characters | LENGTH("Hello") | 5 |
LEFT(s, n) | First n characters | LEFT("Cambridge",4) | "Camb" |
RIGHT(s, n) | Last n characters | RIGHT("Cambridge",5) | "ridge" |
MID(s, pos, n) | n chars from pos | MID("Cambridge",2,3) | "amb" |
UCASE(s) | Convert to uppercase | UCASE("hello") | "HELLO" |
LCASE(s) | Convert to lowercase | LCASE("HELLO") | "hello" |
| Situation | Correct type | Reason |
|---|---|---|
| Counting items (e.g., number of students) | INTEGER | Whole numbers only; no fractions of a student |
| Price, temperature, weight | REAL | Fractional values needed |
| Grade (A, B, C...) | CHAR | Single character |
| Full name, address | STRING | Multiple characters |
| Is logged in? / Has passed? | BOOLEAN | Only true/false needed |
| Age | INTEGER | Age is always a whole number |
| Bank account balance | REAL | Requires pence/cents (decimal) |
= for variable assignment — use ← (= is only for comparison and CONSTANT declarations)INT(3.7) = 3 (truncates, not rounds) — INT truncates towards zero, doesn't round8 questions · Cambridge 9618 standard
INT(7.9) return in Cambridge 9618? Explain why.[2]SPEED_OF_LIGHT with the value 299792458 (an integer). Then declare an integer variable distance and assign it the value 1500000.[3]MID("Cambridge", 4, 3) return? Show your working.[2]| Term | Definition |
|---|
10 questions · 10 marks · 10 minutes