# Cambridge Pseudocode Standards & Identifier Tables

- **Track:** Cambridge IGCSE™ Computer Science (0478 / 0984) (CAMBRIDGE IGCSE 0478)
- **Module:** Section 7: Algorithm Design & Problem-Solving
- **Estimated Duration:** 15 minutes
- **Access:** Open Theory (All-Access for Interactive IDE &amp; Autotests)

---

## Theory & Conceptual Background

In Cambridge International examinations, algorithms written in pseudocode must adhere strictly to the standardized conventions defined in the syllabus. This ensures unambiguous readability and consistency across all computing tasks.

---

## 1. Golden Rules of Cambridge Pseudocode

### 1. Keywords in UPPERCASE

All language reserved words and control structures **must be capitalized**:

- Declarations: `DECLARE`, `CONSTANT`
- Input / Output: `INPUT`, `OUTPUT`
- Selection: `IF`, `THEN`, `ELSE`, `ENDIF`, `CASE`, `OF`, `OTHERWISE`, `ENDCASE`
- Iteration: `FOR`, `TO`, `STEP`, `NEXT`, `WHILE`, `DO`, `ENDWHILE`, `REPEAT`, `UNTIL`
- Subroutines: `PROCEDURE`, `ENDPROCEDURE`, `FUNCTION`, `RETURNS`, `ENDFUNCTION`, `CALL`
- Boolean Literals: `TRUE`, `FALSE`

### 2. Assignment Arrow (`<-`)

In Cambridge pseudocode, the assignment operator is the arrow **`<-`**:

```pseudocode
Counter <- Counter + 1
TaxRate <- 0.175
IsValid <- TRUE
```

*Exam Warning*: Using `=` for assignment (e.g., `Counter = Counter + 1`) is an error. The `=` sign is reserved exclusively as a relational operator for comparing equality.

### 3. Meaningful Identifiers

Variable, constant, and subroutine names must be self-documenting:

- Good: `TotalPrice`, `StudentName`, `Index`, `IsRegistered`
- Often unclear without context: `x`, `temp1`, `a`, `foo`

---

## 2. Standard Cambridge Data Types

  
| Data Type | Description | Exam Literal Examples |
| --- | --- | --- |
| `INTEGER` | Whole numbers (positive, negative, or zero) without fractional parts. | `42`, `-7`, `0` |
| `REAL` | Floating-point numbers with fractional / decimal components. | `3.14159`, `-0.5`, `12.0` |
| `CHAR` | Exactly one alphanumeric character, symbol, or punctuation mark. | `'A'`, `'9'`, `'#'` |
| `STRING` | An ordered sequence of zero or more characters enclosed in double quotes. | `"IGCSE Computer Science"`, `""` |
| `BOOLEAN` | Logical truth values taking only one of two states. | `TRUE`, `FALSE` |

---

## 3. The Identifier Table

An **identifier table** is a useful design aid for recording names, types and purposes:

  
| Identifier | Data Type | Purpose / Description |
| --- | --- | --- |
| `CandidateID` | `STRING` | Unique alphanumeric candidate registration code (e.g. "C1042") |
| `RawMarks` | `INTEGER` | Total raw marks achieved on examination (0 to 100) |
| `Percentage` | `REAL` | Calculated percentage score rounded to one decimal place |
| `IsPassed` | `BOOLEAN` | Flags whether candidate met the minimum passing threshold (>= 50%) |
| `Grade` | `CHAR` | Letter grade awarded ('A', 'B', 'C', 'D', 'E', 'U') |

## Written practice and self-review

A student wrote the following Cambridge pseudocode declarations:

```pseudocode
DECLARE 1stScore : INT
DECLARE Total Score : REAL
```

Identify the three syntax errors in these declarations according to Cambridge pseudocode standards and explain how each should be corrected.

Write an explanation before checking the theory. Check that each claim answers the question, uses the correct concept and explains why it applies. Discuss uncertain points with a teacher. The structured exercise below checks specific facts; it does not automatically mark this explanation.

## Maintainability practice

Use meaningful identifiers, suitable comments, procedures/functions for coherent tasks and named constants for fixed values. In a ticket program, replace x with TicketTotal and a repeated price literal with a named constant; indent the body of each selection and loop. Explain why a comment such as “ignore the terminating -1” is more helpful than repeating “add one” beside Count <- Count + 1. Short conventional loop names can still be clear in context.

---

## Interactive Exercises & Autotest Specifications

### Exercise 1: Exam-Style Check: Cambridge Assignment & Keyword Rules (Multiple choice, 25 XP)

**Instructions:**
Which statement correctly assigns the integer value `25` to the variable `StudentAge` according to Cambridge pseudocode standards?

**Options:**
- **A**: StudentAge = 25
- **B**: StudentAge := 25
- **C**: StudentAge &lt;- 25
- **D**: SET StudentAge TO 25


**Autotest Expectations:**
- **Valid assignment operator chosen**: `selection_match` -> Expected: `opt_arrow`

### Exercise 2: Application: Check the reasoning (Fill in blank, 30 XP)

**Instructions:**
Work out each answer before submitting. Correct integer type name: INT or INTEGER? May an identifier start with a digit: yes or no? Assignment arrow or equality comparison should change a stored value?


**Starter Code:**
```text
{"prompt":"Application: Check the reasoning","template":"1. Correct integer type name: INT or INTEGER? [blank_1]\n2. May an identifier start with a digit: yes or no? [blank_2]\n3. Assignment arrow or equality comparison should change a stored value? [blank_3]","blanks":[{"id":"blank_1"},{"id":"blank_2"},{"id":"blank_3"}],"word_bank":["INTEGER","INT","yes","no","assignment arrow","equals sign"]}
```


### Exercise 3: Independent Practice: A named report (Pseudocode, 30 XP)

**Instructions:**
Read a person's name and integer age, then output the name and age on separate lines. Choose meaningful identifiers.

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.



**Autotest Expectations:**
- **Ordinary report**: `test_case` -> Expected: `{&quot;inputs&quot;:[&quot;Mira&quot;,16],&quot;output&quot;:&quot;Mira\n16&quot;}`
- **Different report**: `test_case` -> Expected: `{&quot;inputs&quot;:[&quot;Noah&quot;,0],&quot;output&quot;:&quot;Noah\n0&quot;}`

### Exercise 4: Application: Maintainable code (Fill in blank, 30 XP)

**Instructions:**
Work out each answer before submitting. Which name describes a sum of costs: TotalCost or x? A named value that stays fixed during execution is a variable or constant? An explanation of why a step is needed belongs in a comment or an input statement?


**Starter Code:**
```text
{"prompt":"Application: Maintainable code","template":"1. Which name describes a sum of costs: TotalCost or x? [blank_1]\n2. A named value that stays fixed during execution is a variable or constant? [blank_2]\n3. An explanation of why a step is needed belongs in a comment or an input statement? [blank_3]","blanks":[{"id":"blank_1"},{"id":"blank_2"},{"id":"blank_3"}],"word_bank":["TotalCost","x","variable","constant","comment","input statement"]}
```


