PSEUDOCODE
ALGORITHM DESIGN AND PROBLEM SOLVING
YEAR 11 - COMPUTER SCIENCE
MS GRACE
Definition
Pseudocode is a structured way of writing algorithms using plain English and
programming-style keywords.
● It is not a programming language, but it helps design and understand
algorithms before coding.
● Cambridge exams require specific pseudocode style (keywords in
CAPS, indentation, clear structure).
Pseudocode Rules (as per syllabus)
● Uses a structured English-like style.
● Keywords are always in uppercase (e.g., IF, THEN, ELSE, FOR, WHILE, REPEAT).
● Indentation is important for readability.
● Input/output uses:
○ INPUT – for data entry
○ OUTPUT – for displaying results
Variables, Constants & Data Types
● Variable: Stores data that can change.
● Constant: Value that does not change.
● Common types: INTEGER, REAL, BOOLEAN, CHAR, STRING.
● Assignment: x ← 10
3. Variables, Constants & Data Types
Example 1: Declaring and assigning
Example 2:Using constants
Practice Questions:
Write pseudocode to declare a variable StudentName as STRING and
assign your name to it.
Write pseudocode to declare a constant HourlyRate = 5000 and calculate
TotalPay for 8 hours.
Input and Output
Input/output uses:
○ INPUT – for data entry
○ OUTPUT – for displaying results
Example 1
Input And Output
Example 02:
Practise Questions
1. Write pseudocode to input a student’s age and output whether
they are a teenager.
2. Write pseudocode to input 3 numbers and output their average.
OPERATORS
OPERATORS
OPERATORS
Practice Questions:
1. Write pseudocode to check if a number is divisible by 5.
2. Write pseudocode to check if Mark is greater than 50 OR equal to 50.
5. Selection (Decision Making)
Selection/ Decision Making
OPERATORS - Examples
Example 1: Arithmetic
Example 2(Logical)
Exercise
1. Write pseudocode to input a number and check if it is even or
odd.
2. Write pseudocode using CASE to display grades: A for 80+, B for
70+, C for 60+, else Fail.
Iteration (Loops)
● FOR … TO … NEXT → known number of repetitions
● WHILE … DO … ENDWHILE → condition checked before loop
● REPEAT … UNTIL → condition checked after loop
Example 1 : FOR
Example 2: PEPEAT
Practise
1. Write pseudocode to display numbers from 10 down to 1 using a FOR loop.
2. Write pseudocode that keeps asking for a number until the user enters a positive
number.