Pseudocode Guide
This guide follows the official Cambridge IGCSE™ Computer Science (0478) syllabus for exams in 2026-2028. Mastering pseudocode is essential for success in Paper 2.
1. General Style
Section titled “1. General Style”Pseudocode is designed to be readable and consistent. In your exam, it will appear in a fixed-width font (like Courier New).
Indentation
Section titled “Indentation”Indentation is used to show which statements belong together (e.g., inside a loop or an IF statement).
- Standard indentation is four spaces.
THENandELSEclauses are only indented by two spaces.
Case and Identifiers
Section titled “Case and Identifiers”- Keywords are always in UPPER CASE (e.g.,
IF,WHILE,PROCEDURE). - Identifiers (names for variables, constants, etc.) use PascalCase (e.g.,
TotalToPay,StudentName). - Identifiers must start with a capital letter and can only contain letters and digits (no underscores).
Comments
Section titled “Comments”Use two forward slashes // to add notes to your code.
// This is a single line commentCounter ← 0 // You can also add comments at the end of a line2. Variables and Data Types
Section titled “2. Variables and Data Types”Data Types
Section titled “Data Types”IGCSE Computer Science uses five basic data types:
INTEGER: Whole numbers (e.g.,5,-10).REAL: Numbers with fractional parts (e.g.,3.14,-0.5).CHAR: A single character (e.g.,'A','@').STRING: A sequence of characters (e.g.,"Hello World","").BOOLEAN: Logical valuesTRUEorFALSE.
Declarations
Section titled “Declarations”Always declare your variables before using them.
DECLARE Counter : INTEGERDECLARE AverageScore : REALDECLARE IsFound : BOOLEANConstants
Section titled “Constants”Use constants for values that do not change. This makes your code easier to maintain.
CONSTANT Pi ← 3.14159CONSTANT MaxStudents ← 303. Basic Operations
Section titled “3. Basic Operations”Assignment
Section titled “Assignment”Use the left arrow ← to assign a value to a variable.
Total ← 0Name ← "Alex"Input and Output
Section titled “Input and Output”INPUT: Gets a value from the user.OUTPUT: Displays information on the screen.
OUTPUT "Please enter your name:"INPUT UserNameOUTPUT "Hello, ", UserNameArithmetic Operators
Section titled “Arithmetic Operators”+(Addition)-(Subtraction)*(Multiplication)/(Division)^(Power of)DIV(x, y): Integer division (returns the whole number part).MOD(x, y): Modulus (returns the remainder).
Result ← DIV(10, 3) // Result is 3Remainder ← MOD(10, 3) // Remainder is 14. String Handling
Section titled “4. String Handling”String handling allows you to manipulate text. Positions in a string generally start at 1.
LENGTH(String): Returns the number of characters.LCASE(String): Converts to lower case.UCASE(String): Converts to upper case.SUBSTRING(String, Start, Length): Extracts a part of the string.
MyText ← "Computer Science"LengthText ← LENGTH(MyText) // returns 16ShortText ← SUBSTRING(MyText, 1, 8) // returns "Computer"5. Selection (Decision Making)
Section titled “5. Selection (Decision Making)”IF Statements
Section titled “IF Statements”Used to execute code only if a condition is true.
IF Score >= 50THEN OUTPUT "Pass"ELSE OUTPUT "Fail"ENDIFCASE Statements
Section titled “CASE Statements”Used when you have multiple specific values to check.
CASE OF Grade 'A' : OUTPUT "Excellent" 'B' : OUTPUT "Good" 'C' : OUTPUT "Satisfactory" OTHERWISE OUTPUT "Improvement needed"ENDCASE6. Iteration (Loops)
Section titled “6. Iteration (Loops)”FOR Loops (Count-controlled)
Section titled “FOR Loops (Count-controlled)”Use when you know exactly how many times the loop should run.
FOR i ← 1 TO 10 OUTPUT iNEXT i
// Using a STEPFOR j ← 10 TO 0 STEP -2 OUTPUT jNEXT jWHILE Loops (Pre-condition)
Section titled “WHILE Loops (Pre-condition)”Runs while a condition is true. The condition is checked before the loop runs.
WHILE Counter < 10 DO Counter ← Counter + 1ENDWHILEREPEAT UNTIL Loops (Post-condition)
Section titled “REPEAT UNTIL Loops (Post-condition)”Runs until a condition is true. The loop always runs at least once.
REPEAT OUTPUT "Enter a positive number:" INPUT NumberUNTIL Number > 07. Arrays
Section titled “7. Arrays”1D Arrays
Section titled “1D Arrays”DECLARE StudentNames : ARRAY[1:30] OF STRINGStudentNames[1] ← "Ali"2D Arrays
Section titled “2D Arrays”DECLARE Grid : ARRAY[1:3, 1:3] OF CHARGrid[2, 3] ← 'X'8. Procedures and Functions
Section titled “8. Procedures and Functions”Procedures
Section titled “Procedures”A block of code that performs a task but does not return a value.
PROCEDURE WelcomeUser(Name : STRING) OUTPUT "Welcome, ", NameENDPROCEDURE
// Calling a procedureCALL WelcomeUser("Sam")Functions
Section titled “Functions”A block of code that performs a task and returns a single value.
FUNCTION Square(Number : INTEGER) RETURNS INTEGER RETURN Number * NumberENDFUNCTION
// Using a function in an expressionArea ← Square(SideLength)9. File Handling
Section titled “9. File Handling”Files allow you to store data permanently.
OPENFILE <filename> FOR <mode>(Modes:READ,WRITE)READFILE <filename>, <variable>WRITEFILE <filename>, <variable>CLOSEFILE <filename>
OPENFILE "Scores.txt" FOR WRITEWRITEFILE "Scores.txt", PlayerScoreCLOSEFILE "Scores.txt"10. Library Routines
Section titled “10. Library Routines”Common built-in tools:
ROUND(Value, Places): Rounds to specified decimal places.RANDOM(): Returns a random number between 0 and 1.