Unable to open this exercise
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 |
|
|
| Subtraction |
|
|
| Multiplication |
|
|
| Real Division |
|
|
| Exponentiation (Power) |
|
|
3. Operator Precedence (BODMAS / PEMDAS)
When an expression contains multiple operators, operations are executed in a strict hierarchy:
- Brackets
(...): Expressions inside parentheses evaluate first. - Exponents
^: Evaluated next. - Multiplication
*and Division/: Evaluated left to right. - 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 |
|
|
| Not equal to |
|
|
| Less than |
|
|
| Less than or equal to |
|
|
| Greater than |
|
|
| Greater than or equal to |
|
|
AI Socratic Tutor
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
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.
Interactive exercises for Module 2 and beyond require an active plan.
Run code to inspect step-by-step variable trace states.