Pseudocode Foundations & Conventions: Input, Output And Assignment Statements (Copy)
Input, Output And Assignment Statements
Role Of Input, Output And Assignment In Pseudocode
- These statements form the core execution flow of any algorithm
- Examiner checks:
- Correct data entry (INPUT)
- Correct data storage (assignment)
- Correct data display (OUTPUT)
- Incorrect usage causes:
- Logic failure
- Loss of easy method marks
INPUT Statements (Receiving Data)
| Rule | Correct Practice |
|---|---|
| One variable per INPUT | Avoid confusion |
| Clear variable name | Meaning must be obvious |
| No prompts inside INPUT | Prompts go in OUTPUT |
Correct INPUT Usage
INPUT Age
INPUT Name
INPUT Marks
INPUT With User Guidance (Examiner-Friendly)
OUTPUT "Enter age"
INPUT Age
- OUTPUT gives instruction
- INPUT only receives data
Common INPUT Mistakes And Fixes
| Mistake | Why Wrong | Correct Form |
|---|---|---|
| INPUT “Enter age” | INPUT not for text | OUTPUT then INPUT |
| INPUT Age, Name | Ambiguous | Separate INPUT lines |
| READ Age | Language-specific | Use INPUT |
Assignment Statements (Storing Values)
| Feature | Correct Usage |
|---|---|
| Assignment symbol | ← |
| One assignment per line | Clarity |
| Left side = variable | Must already exist |
Simple Assignment
Total ← 0
Name ← "Ali"
Found ← FALSE
Assignment Using Calculation
Sum ← Sum + Value
Average ← Total / Count
- ← is never used for comparison
- = is never used for assignment
Assignment vs Comparison (Critical Distinction)
| Purpose | Symbol | Example |
|---|---|---|
| Assignment | ← | Total ← 10 |
| Comparison | = | IF Total = 10 THEN |
Examiner-Safe Example
Total ← 10
IF Total = 10 THEN
OUTPUT "Correct"
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
OUTPUT Statements (Displaying Results)
| Rule | Correct Practice |
|---|---|
| Always label values | Improves clarity |
| Combine text + variable | Examiner-friendly |
| Avoid language keywords | No PRINT |
Correct OUTPUT Examples
OUTPUT "Total = ", Total
OUTPUT "Average = ", Average
OUTPUT "Name = ", Name
OUTPUT Text Only
OUTPUT "Invalid input"
OUTPUT Formatting Rules
| Incorrect | Issue | Correct |
|---|---|---|
| OUTPUT Total | Meaning unclear | OUTPUT “Total = “, Total |
| OUTPUT Avg | No label | OUTPUT “Average = “, Avg |
- Labels help examiner award marks quickly
Combining INPUT, Assignment And OUTPUT (Core Pattern)
DECLARE Num1 : INTEGER
DECLARE Num2 : INTEGER
DECLARE Sum : INTEGER
INPUT Num1
INPUT Num2
Sum ← Num1 + Num2
OUTPUT "Sum = ", Sum
- Clean flow:
- Input → Process → Output
Assignment With Counters And Totals
Counter Pattern
Count ← 0
Count ← Count + 1
Total Pattern
Total ← 0
Total ← Total + Value
- Must initialise before use
- Used heavily in loops
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
INPUT Inside Loops (Very Common Exam Pattern)
Fixed Count Input (FOR Loop)
Total ← 0
FOR i ← 1 TO 5
INPUT Mark
Total ← Total + Mark
ENDFOR
OUTPUT "Total = ", Total
Validation Input (REPEAT UNTIL)
REPEAT
INPUT Age
UNTIL Age >= 0 AND Age <= 120
- Ensures valid data
- Examiner-approved logic
OUTPUT Inside Loops (Tracing Friendly)
FOR i ← 1 TO 3
OUTPUT "Value = ", i
ENDFOR
- Output clearly linked to loop variable
- Easy to trace step-by-step
Assignment Inside Conditional Statements
IF Score >= 50 THEN
Result ← "Pass"
ELSE
Result ← "Fail"
ENDIF
OUTPUT Result
| Benefit | Reason |
|---|---|
| Cleaner logic | Output separated |
| Easy marking | Clear decision result |
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
Multiple Assignment Steps (Readable Approach)
Poor (compressed)
A←B+C+D
Examiner-Friendly
Temp ← B + C
A ← Temp + D
- Shows working
- Reduces logical ambiguity
Assignment With Boolean Flags
Found ← FALSE
IF Value = Target THEN
Found ← TRUE
ENDIF
- Flag variables control flow
- Must be initialised
INPUT / OUTPUT With Arrays
Input Into Array
FOR i ← 1 TO 5
INPUT Marks[i]
ENDFOR
Output From Array
FOR i ← 1 TO 5
OUTPUT "Mark = ", Marks[i]
ENDFOR
- Index clearly visible
- No guessing for examiner
INPUT / OUTPUT With Records
INPUT Student.Name
INPUT Student.Age
INPUT Student.Score
OUTPUT "Name = ", Student.Name
OUTPUT "Score = ", Student.Score
- Field-level clarity
- Structured data access
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
Common Examiner Traps And Fixes
| Trap | Why It Loses Marks | Correct Action |
|---|---|---|
| Using = for assignment | Logic error | Use ← |
| Unlabelled OUTPUT | Ambiguous result | Add text |
| INPUT with text | Syntax misuse | OUTPUT then INPUT |
| No initialisation | Undefined values | Initialise first |
| Mixed multiple actions | Hard to trace | One per line |
Examiner-Safe INPUT–PROCESS–OUTPUT Template
DECLARE variables
Initialise variables
INPUT data
Process logic using assignment
OUTPUT labelled results
- Safe under exam pressure
- Matches marking scheme expectations
