Pseudocode Foundations & Conventions: Writing Clear And Examiner-Friendly Pseudocode (Copy)
Writing Clear And Examiner-Friendly Pseudocode
What “Examiner-Friendly” Means In Practice
- Logic must be readable without assumptions
- Every step should be traceable line-by-line
- Examiner should immediately see:
- What the program is doing
- Why a decision is taken
- When a loop stops
- Ambiguity reduces marks even if logic is mostly correct
Golden Rules For Examiner-Friendly Pseudocode
| Rule | What To Do | Examiner Benefit |
|---|---|---|
| One action per line | One instruction per line | Easy mark allocation |
| Clear indentation | Indent all blocks consistently | Visual logic clarity |
| Explicit logic | Write full conditions | No guessing |
| Proper endings | ENDIF, ENDFOR, etc. | Prevents logic loss |
| Simple flow | Avoid clever shortcuts | Reliable marking |
Line-By-Line Clarity Principle
Poor (hard to trace)
IF Age>=18 THEN OUTPUT "Allowed" ELSE OUTPUT "Denied"
Examiner-Friendly
IF Age >= 18 THEN
OUTPUT "Allowed"
ELSE
OUTPUT "Denied"
ENDIF
- Same logic
- Higher clarity
- Lower risk of misinterpretation
Variable Naming For Maximum Clarity
| Poor Name | Issue | Better Name |
|---|---|---|
| x | Meaningless | TotalMarks |
| a1 | Confusing | StudentAge |
| flag | Vague | Found |
| t | Ambiguous | Total |
- Variable names must describe purpose
- Examiner should understand meaning instantly
Declaration And Initialisation Discipline
| Purpose | Pattern |
|---|---|
| Declaration | DECLARE Count : INTEGER |
| Initialisation | Count ← 0 |
Examiner-Safe Setup
DECLARE Total : INTEGER
DECLARE Count : INTEGER
DECLARE Found : BOOLEAN
Total ← 0
Count ← 0
Found ← FALSE
- Prevents undefined behaviour
- Shows structured thinking
Written and Compiled By Sir Hunain Zia (AYLOTI), World Record Holder With 154 Total A Grades, 7 Distinctions And 11 World Records For Educate A Change AS Level Computer Science Full Scale Course
Writing Conditions That Cannot Be Misread
| Weak Condition | Problem | Strong Condition |
|---|---|---|
| IF Age > 18 | Edge unclear | IF Age >= 18 |
| IF Flag | Ambiguous | IF Flag = TRUE |
| IF NOT Found | Risky | IF Found = FALSE |
Clear Condition Example
IF (Score >= 50) AND (Attendance >= 80) THEN
OUTPUT "Pass"
ELSE
OUTPUT "Fail"
ENDIF
- Brackets improve readability
- Compound logic made explicit
Selection Structures With Clean Decision Flow
Simple IF
IF Temperature > 30 THEN
OUTPUT "Hot"
ENDIF
IF–ELSE
IF Balance >= Amount THEN
OUTPUT "Transaction Approved"
ELSE
OUTPUT "Insufficient Funds"
ENDIF
Nested IF
IF Age >= 18 THEN
IF HasID = TRUE THEN
OUTPUT "Entry Allowed"
ELSE
OUTPUT "ID Required"
ENDIF
ELSE
OUTPUT "Underage"
ENDIF
- Each IF handles one decision
- No mixed responsibilities
CASE Statements For Fast Examiner Tracing
| Use CASE When | Reason |
|---|---|
| Menu systems | Cleaner than nested IF |
| Fixed options | Faster marking |
INPUT Option
CASE Option OF
1 : OUTPUT "Add Record"
2 : OUTPUT "Delete Record"
3 : OUTPUT "Search Record"
OTHERWISE : OUTPUT "Invalid Option"
ENDCASE
Written and Compiled By Sir Hunain Zia (AYLOTI), World Record Holder With 154 Total A Grades, 7 Distinctions And 11 World Records For Educate A Change AS Level Computer Science Full Scale Course
Loop Choice Clarity
| Loop | Use When |
|---|---|
| FOR | Known number of repetitions |
| WHILE | Condition-based repetition |
| REPEAT UNTIL | Must run at least once |
FOR Loop (Count-Controlled)
Total ← 0
FOR i ← 1 TO 5
INPUT Mark
Total ← Total + Mark
ENDFOR
OUTPUT "Total = ", Total
WHILE Loop (Pre-Condition)
Count ← 0
WHILE Count < 3 DO
INPUT Value
Count ← Count + 1
ENDWHILE
- Condition checked before execution
REPEAT UNTIL Loop (Validation Pattern)
REPEAT
INPUT Age
UNTIL Age >= 0 AND Age <= 120
- Executes at least once
- Clear stopping condition
Avoiding Infinite Loops
| Cause | Fix |
|---|---|
| Counter not updated | Increment inside loop |
| Incorrect condition | Rewrite logic |
| Flag never changes | Update flag inside loop |
Written and Compiled By Sir Hunain Zia (AYLOTI), World Record Holder With 154 Total A Grades, 7 Distinctions And 11 World Records For Educate A Change AS Level Computer Science Full Scale Course
Procedures: Clean Task Separation
| Rule | Explanation |
|---|---|
| One task | One procedure |
| Clear naming | Verb-based |
| Explicit parameters | No hidden values |
PROCEDURE DisplayGrade(Mark : INTEGER)
IF Mark >= 50 THEN
OUTPUT "Pass"
ELSE
OUTPUT "Fail"
ENDIF
ENDPROCEDURE
CALL DisplayGrade(Score)
Functions: Return-Value Precision
FUNCTION CalculateAverage(Total : INTEGER, Count : INTEGER) RETURNS REAL
RETURN Total / Count
ENDFUNCTION
Average ← CalculateAverage(Sum, Number)
| Common Error | Correct Fix |
|---|---|
| Missing RETURN | Always return a value |
| Used like procedure | Assign return value |
Arrays: Clear Traversal Logic
Declaration
DECLARE Marks : ARRAY[1:10] OF INTEGER
Processing
Total ← 0
FOR i ← 1 TO 10
Total ← Total + Marks[i]
ENDFOR
Linear Search (Exam-Safe Pattern)
Found ← FALSE
i ← 1
WHILE i <= N AND Found = FALSE DO
IF Data[i] = Target THEN
Found ← TRUE
ELSE
i ← i + 1
ENDIF
ENDWHILE
IF Found = TRUE THEN
OUTPUT "Found at position ", i
ELSE
OUTPUT "Not found"
ENDIF
Written and Compiled By Sir Hunain Zia (AYLOTI), World Record Holder With 154 Total A Grades, 7 Distinctions And 11 World Records For Educate A Change AS Level Computer Science Full Scale Course
Records: Making Structure Obvious
RECORD StudentType
Name : STRING
Age : INTEGER
Mark : INTEGER
ENDRECORD
DECLARE Student : StudentType
INPUT Student.Name
INPUT Student.Age
INPUT Student.Mark
Text File Handling (Stepwise And Safe)
OPENFILE DataFile FOR READ
WHILE NOT EOF(DataFile) DO
READFILE DataFile, Line
OUTPUT Line
ENDWHILE
CLOSEFILE DataFile
| Examiner Expectation | Present |
|---|---|
| EOF check | Yes |
| Read inside loop | Yes |
| File closed | Yes |
Output Labelling For Easy Marks
| Poor | Correct |
|---|---|
| OUTPUT Total | OUTPUT “Total = “, Total |
| OUTPUT Avg | OUTPUT “Average = “, Avg |
Examiner-Safe Checklist
| Checkpoint | Status |
|---|---|
| Variables declared | ✓ |
| Variables initialised | ✓ |
| Correct loop type | ✓ |
| All blocks closed | ✓ |
| Outputs labelled | ✓ |
| Logic traceable | ✓ |
