Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
This Assigned value must match the variable's data type worksheet is part of the IGCSE Computer Science 0478 — 8.1a Data Types and Variables journey. Print it as a booklet?
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1DECLARE Age : INTEGER Age ← "Ali" | AType mismatch: text is assigned to an INTEGER variable. Score should be given a whole number such as 45. | |
| 2DECLARE Grade : CHAR Grade ← 'B' | BA correct assignment: a single character in single quotes matches the CHAR type | |
| 3A STRING variable must be given text inside double quotes | CDECLARE Initial : CHAR Initial ← 'A' | |
| 4A CHAR variable must be given a single character inside single quotes | DDECLARE Name : STRING Name ← "Ali" | |
| 5DECLARE Score : INTEGER Score ← "Ali" | EA CHAR value needs single quotes, not double quotes. It should be Letter ← 'A'. | |
| 6DECLARE Letter : CHAR Letter ← "A" | FA type mismatch: the text "Ali" cannot be stored in an INTEGER variable |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
type mismatch — An error when a value assigned to a variable has a different data type from the one it was declared with, such as storing a name in an INTEGER variable.DECLARE Age : INTEGER
Age ← 15DECLARE Name : STRING
Name ← "Ali"DECLARE Grade : CHAR
Grade ← 'A'DECLARE Town : STRING
Town ← "Leeds"DECLARE Initial : CHAR
Initial ← 'K'