4.1 Assignment Statements
An assignment statement stores a value into a variable. In CIE pseudocode the assignment operator is the left-pointing arrow <-, which you can read aloud as "becomes" or "gets".
Syntax
<Variable> <- <Value or Expression>Examples
Score <- 100
Price <- 9.99
Name <- "Alice"
Total <- Price * Quantity
Counter <- Counter + 1The right-hand side is evaluated first, and the result is then stored in the variable on the left. This is why Counter <- Counter + 1 works — it means "take the current value of Counter, add 1, and store it back into Counter".
Watch out: Do NOT use = for assignment. In CIE pseudocode = means "is equal to" (a comparison), not assignment. Examiners deduct marks for using = instead of <-.
Assignment
4.2 The INPUT Statement
The INPUT statement reads a value from the keyboard (or another input device) and stores it in a variable. The program pauses until the user types something and presses Enter.
Syntax
INPUT <Variable>Examples
DECLARE Name : STRING
DECLARE Age : INTEGER
INPUT Name
INPUT AgeNotice that the variable must be declared first, before you can read a value into it. The variable's data type decides what kind of input the program expects.
Best practice: Always print a helpful prompt with OUTPUT just before INPUT, so the user knows what to type. Example:
OUTPUT "Please enter your name: "
INPUT NameINPUT
4.3 The OUTPUT Statement
The OUTPUT statement displays information on the screen. You can print text (in double quotes), the value of variables, or a mixture of both — joined together with the + operator.
Syntax
OUTPUT <Item1> [+ <Item2> + ...]Examples
OUTPUT "Hello, world!"
OUTPUT Name
OUTPUT "Your score is " + Score
OUTPUT "Total: " + Price * QuantityText inside double quotes (a string literal) is printed exactly as written. A variable name without quotes is replaced by its current value. The + operator joins (concatenates) them into a single line of output.
New lines: Each separate OUTPUT statement prints on a new line. So two OUTPUT statements produce two lines of output, even if they are right next to each other.
OUTPUT
4.4 Combining Input and Output
Most useful programs follow the same three-step pattern:
- Declare the variables you will need.
- INPUT values from the user (with helpful prompts).
- Process the data and OUTPUT the results.
Worked Example: Greeting the User
DECLARE Name : STRING
OUTPUT "What is your name? "
INPUT Name
OUTPUT "Hello, " + Name + " — welcome!"If the user types Aisha, the program prints:
Hello, Aisha — welcome!Worked Example: Doubling a Number
DECLARE N : INTEGER
DECLARE Doubled : INTEGER
OUTPUT "Enter a whole number: "
INPUT N
Doubled <- N * 2
OUTPUT "Double of " + N + " is " + DoubledOrder matters: INPUT must always come before you try to use the value. If you assign a value first and then INPUT into the same variable, the user's input will overwrite your assignment — making the earlier line pointless.
Common Mistakes
4.5 Practical Examples
Here are three short but complete programs that bring together everything you have learned. Read each one carefully and try to predict the output before reading the explanation.
Example 1: Area of a Rectangle
DECLARE Length : REAL
DECLARE Width : REAL
DECLARE Area : REAL
OUTPUT "Enter the length: "
INPUT Length
OUTPUT "Enter the width: "
INPUT Width
Area <- Length * Width
OUTPUT "The area is " + AreaTwo values are read in (Length and Width), multiplied, and the result is stored in Area before being displayed. Notice the variables are REAL because lengths can have decimal parts.
Example 2: Updating a Counter
DECLARE Counter : INTEGER
Counter <- 0
OUTPUT "Counter starts at " + Counter
Counter <- Counter + 1
Counter <- Counter + 1
OUTPUT "After two increases, Counter is " + CounterThis program prints Counter starts at 0 and then After two increases, Counter is 2. Each Counter <- Counter + 1 line adds 1 to the current value.
Example 3: Swapping Two Values
DECLARE A : INTEGER
DECLARE B : INTEGER
DECLARE Temp : INTEGER
A <- 5
B <- 9
Temp <- A
A <- B
B <- Temp
OUTPUT "A = " + A + ", B = " + BTo swap two values, you need a temporary variable (Temp). First save A into Temp, then move B into A, then move Temp (the original A) into B. After the swap, A is 9 and B is 5. The program prints A = 9, B = 5.
Tracing Programs
4.6 Key Points Summary
Let's recap the most important ideas from this topic before you tackle the Question Bank.
Exam tip: In CIE exams, always write pseudocode with UPPERCASE keywords (DECLARE, INPUT, OUTPUT) and use the <- arrow for assignment. Examiners deduct marks for using = instead of <-, and for forgetting to DECLARE variables before use.