Published by Patrick Mutisya · 14 days ago
Write correct pseudocode statements that assign values to variables, using the appropriate syntax and respecting the rules for variable names and data types.
An assignment stores a value in a variable. In pseudocode the assignment operator is written as :=. The general form is:
\$\text{variable} \; := \; \text{expression}\$
After the statement is executed, the variable holds the result of the expression.
IF, FOR, WHILE, BEGIN, END.totalScore, studentName).Common data types used in A‑Level pseudocode are:
| Data Type | Example Literal | Description |
|---|---|---|
| Integer | 42 | Whole numbers, positive or negative. |
| Real | 3.14 | Numbers with a fractional part. |
| Boolean | TRUE, FALSE | Logical values. |
| String | "Hello" | Sequence of characters enclosed in double quotes. |
INTEGER totalScore.:=.INTEGER ageage := 18
INTEGER a, b, suma := 7
b := 5
sum := a + b // sum now holds 12
Complex expressions can be evaluated in a single assignment:
REAL radius, arearadius := 3.5
area := 3.14159 * radius * radius // area = πr²
STRING firstName, lastName, fullNamefirstName := "Ada"
lastName := "Lovelace"
fullName := firstName & " " & lastName // fullName = "Ada Lovelace"
BOOLEAN isPassscore := 78
isPass := score >= 50 // isPass becomes TRUE
a, b, c := 1, 2, 3 // a=1, b=2, c=3= instead of :=).counter and initialise it to 0.TRUE in a Boolean variable passed if the mark is 40 or above.REAL length, width, area, assign the product of length and width to area.greeting that concatenates the word “Hello”, a space, and a variable name (which already holds a student's name).x, y, z to the values 10, 20, and 30 respectively.