User Input & Standard Arithmetic Operations

Interactive computing requires reading data dynamically from users and applying arithmetic transformations according to mathematical precedence rules.


1. Accepting Input (INPUT)

The INPUT statement reads data from an external input device (e.g. keyboard) and stores it in a declared variable:

DECLARE StudentAge : INTEGER
OUTPUT "Please enter your age: "
INPUT StudentAge

2. Standard Arithmetic Operators

Cambridge pseudocode supports the five fundamental mathematical operators:

Operator

Operation

Exam Example

Result

+

Addition

12 + 8

20

-

Subtraction

25 - 9

16

*

Multiplication

6 * 7

42

/

Real Division

15 / 2

7.5

^

Exponentiation (Power)

2 ^ 3

8


3. Operator Precedence (BODMAS / PEMDAS)

When an expression contains multiple operators, operations are executed in a strict hierarchy:

  1. Brackets (...): Expressions inside parentheses evaluate first.
  2. Exponents ^: Evaluated next.
  3. Multiplication * and Division /: Evaluated left to right.
  4. Addition + and Subtraction -: Evaluated left to right.
// Without parentheses (Multiplication first):
Result <- 10 + 5 * 2       // 10 + 10 = 20

// With parentheses:
Result <- (10 + 5) * 2     // 15 * 2 = 30

4. Cambridge Relational Operators

Relational operators compare two values and evaluate to a BOOLEAN result (TRUE or FALSE):

Operator

Meaning

True Condition Example

False Condition Example

=

Equal to

5 = 5

5 = 6

<>

Not equal to

5 <> 6

5 <> 5

<

Less than

3 < 7

7 < 3

<=

Less than or equal to

5 <= 5

6 <= 5

>

Greater than

9 > 4

4 > 9

>=

Greater than or equal to

8 >= 8

7 >= 8

AI Socratic Tutor

All-Access
Sign in or create an account. AI Tutor is an All-Access benefit.
Sign Up

Need guidance? Ask a question or use the hint below.

AI Socratic Tutor is an All-Access Benefit

Unlock step-by-step Socratic hints, algorithm trace table walkthroughs, and error diagnostics for every Cambridge exercise.

You're chatting with an AI tutor, not a person. AI can make mistakes, so double-check its answers.

Independent Practice: Rectangle measurements

+30 XP

Read positive integer length then width. Output area followed by perimeter. Choose the correct formula for each; do not confuse the two measurements.

Write a complete program. Read inputs in the stated order. Output only the requested results, one per line, without input prompts. Test with your own values before submitting.

solution.pseudo
All-Access Required

Interactive exercises for Module 2 and beyond require an active plan.

○ Unequal sides
○ Unit square
○ Different rectangle