Fundamentals

Input, Output & Assignment

Programs talk to the world: they read data in, store it in variables, and write results out. Master the three core statements — assignment, INPUT and OUTPUT — using proper CIE pseudocode syntax.

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 + 1

The 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 <-.

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 Age

Notice 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 Name

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 * Quantity

Text 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.

4.4 Combining Input and Output

Most useful programs follow the same three-step pattern:

  1. Declare the variables you will need.
  2. INPUT values from the user (with helpful prompts).
  3. 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 " + Doubled

Order 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.

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 " + Area

Two 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 " + Counter

This 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 = " + B

To 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.

4.6 Key Points Summary

Let's recap the most important ideas from this topic before you tackle the Question Bank.

Assignment uses the <- arrow, NOT =. Read it as "becomes".
INPUT reads a value from the keyboard and stores it in a variable.
OUTPUT displays text or values on the screen.
Always DECLARE a variable before you INPUT or assign to it.
Use OUTPUT before INPUT to give the user a helpful prompt.
Text in double quotes is printed exactly; variable names print their value.
Join text and values with the + operator inside an OUTPUT statement.
Each separate OUTPUT statement prints on a new line.

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.

Question Bank

Answer all 12 questions, then submit to see your score.

Answered 0 / 12

Question 1Multiple Choice

Which symbol is used for assignment in CIE pseudocode?

Question 2True / False

In CIE pseudocode, the INPUT statement is used to read data typed by the user at the keyboard.

Question 3Multiple Choice

What does this statement do?

OUTPUT "Hello, world!"

Question 4Multiple Choice

Which of these is a valid INPUT statement in CIE pseudocode?

Question 5True / False

In CIE pseudocode, the statement Age <- Age + 1 means "increase the value of Age by 1".

Question 6Multiple Choice

Trace this program. What is OUTPUT when the user types 5?

DECLARE N : INTEGER
INPUT N
N <- N + 10
OUTPUT N

Question 7Multiple Choice

Which statement is used to display text and the value of a variable on the same line in CIE pseudocode?

Question 8True / False

In CIE pseudocode, the assignment operator <- can be read aloud as "becomes" or "gets".

Question 9Multiple Choice

What is wrong with this pseudocode?

INPUT Score
DECLARE Score : INTEGER

Question 10Multiple Choice

Look at this pseudocode. What is the OUTPUT?

DECLARE Name : STRING
Name <- "Aisha"
OUTPUT "Hi " + Name

Question 11True / False

The OUTPUT statement can display both text (in quotes) and the value of variables in the same statement.

Question 12Multiple Choice

A program needs to ask the user for their test score and then display a message with that score. Which set of statements is correctly ordered?