Show understanding that an algorithm is a solution to a problem expressed as a sequence of steps
Use suitable identifier names for representation of data used by a problem and represent these using an identifier table
Write pseudocode that contains input, process and output
Write pseudocode using three basic constructs: sequence, selection and iteration
Document simple algorithms using pseudocode
Write pseudocode from structured English descriptions and flowcharts
Describe and use the process of stepwise refinement
Use logic statements to define parts of an algorithm solution
📖 Prior Knowledge Required
Basic understanding of problem-solving approaches
Familiarity with mathematical operations and logic
Understanding of data types (INTEGER, REAL, STRING, BOOLEAN, CHAR)
Basic knowledge of variables and constants
Understanding of input and output concepts
🌟 Did You Know?
Algorithms are one of the four cornerstones of Computer Science. If you can tie shoelaces, make a cup of tea, get dressed, or prepare a meal then you already know how to follow an algorithm! Computers are only as good as the algorithms they are given - a poor algorithm will produce a poor result.
1. What is an Algorithm?
📖 Definition
An algorithm is a solution to a problem expressed as a sequence of defined steps. It is a plan, a set of step-by-step instructions to solve a problem.
Many problems have more than one solution. Sometimes it is a personal preference which solution to choose. Sometimes one solution will be better than another. A good solution gives correct results, takes up little computer memory, and executes as fast as possible. The solution should be concise, elegant, and easy to understand.
1.1 Methods of Expressing Algorithms
We express solutions (algorithms) using sequences of steps written in different ways:
Method
Description
Structured English
A subset of English language consisting of command statements. Uses clear English phrases to describe each step. Logic structures like IF...THEN, REPEAT, and WHILE may appear but without strict syntax rules.
Pseudocode
Resembles a programming language without following the syntax of a particular language. It is precise, structured, and language-independent. Follows exam-board-defined syntax.
Flowchart
A graphical representation of an algorithm using specific shapes linked together. Used to visualise the flow of control in a system.
Programming Statement
Resembles pseudocode but follows the particular syntax of a programming language.
💡 Exam Tip
When asked about methods of expressing algorithms, mention all four methods and briefly describe each. Structured English is often used in early planning stages before converting to pseudocode.
2. Algorithm Basic Constructs
When writing algorithms, four basic types of construct are used:
📖 The Four Basic Constructs
Assignment: An instruction that places a value into a specified variable or constant using the ← operator
Sequence: Programming statements executed one after another in the order they appear
Selection: A control structure where a test decides if certain instructions are executed (IF-THEN-ELSE, CASE-OF)
Repetition (Iteration): A control structure where statements are executed repeatedly (FOR, WHILE, REPEAT-UNTIL)
2.1 Algorithm Activities (Input - Process - Output)
Algorithm solutions involve inputting data to the computer, processing the data, and outputting results. An algorithm usually consists of three types of activity:
Activity
Description
Example
Input
Getting a value from the user, reading a line of text from a file
INPUT "Enter your age" age
Process
Assignment statements, calculations, use of built-in functions
sum ← num1 + num2
Output
Displaying output on screen, writing data to a file
OUTPUT "The answer is: " sum
Example: Convert a distance in miles into km and output the equivalent distance. Step 1 (Structured English): INPUT number of miles → Calculate km (miles × 1.61) → OUTPUT result Step 2 (Pseudocode):
DECLARE Miles : REAL
INPUT "Enter miles: " Miles
Km ← Miles * 1.61
OUTPUT "km: " Km
3. Data Storage Elements
3.1 Variables and Constants
📖 Variable
A variable is a memory location which temporarily stores data that can change while the program is running. Each variable should be given a unique name called an identifier. Variable names are symbolic representations of memory locations.
DECLARE <identifier> : <data type>
// Examples:
DECLARE count : INTEGER
DECLARE Average : REAL
DECLARE Name : STRING
📖 Constant
A constant is a memory location which stores data that remains the same throughout the execution of the program. Use of constants helps prevent accidental changes when writing programs.
CONSTANT <identifier> ← <value>
// Examples:
CONSTANT Temperature ← 26.87
CONSTANT BookTitle ← "CS MADE EASY"
CONSTANT MaxScore ← 100
3.2 Arrays
📖 Array
An array is a data structure that can store a fixed-size collection of elements of the same type. Arrays allow you to store multiple values under a single identifier, accessed using an index.
DECLARE <identifier> : ARRAY[<lower>:<upper>] OF <data type>
// Example:
DECLARE Scores : ARRAY[1:10] OF INTEGER
3.3 Identifier Tables and Naming Rules
Variables, constants, arrays, procedures, and functions names are known as identifiers.
⚠️ Identifier Naming Rules
There should be no space in a name
Name should not be a keyword of the programming language
Name should be relevant and meaningful
Names should start with an alphabet (e.g., "4number" is invalid)
Can include letters, digits, and underscores only
Valid Identifiers
Invalid Identifiers
First_Name
1Sum (starts with digit)
PostCode
First Name (contains space)
AverageHeight
Total% (contains % symbol)
TestScore, Num1, Total
my-var (contains hyphen)
4. Assignment Operators
Values are assigned to constants, arrays, and variables using the ← operator (or input statements). The variable on the left of ← is assigned the value of the expression on the right.
📝 Types of Assignment Operations
1. Simple Assignment:
Cost ← 10
2. Updating a Value:
Cost ← Cost + 2 // Cost now equals 12
3. Copying a Value:
Price ← Cost // Price gets the value of Cost
4.1 Swapping Two Values
To swap the contents of two variables, we need to store one value temporarily. Otherwise, the second value will be overwritten by the first value.
📝 Swapping Algorithm
Temp ← Value1 // Store Value1 temporarily
Value1 ← Value2 // Value1 now has Value2's content
Value2 ← Temp // Value2 now has original Value1's content
❌ Common Mistake
Students often try to swap directly without a temporary variable:
// WRONG - this loses the original Value1!
Value1 ← Value2
Value2 ← Value1 // Value1 already contains Value2!
4.2 Variable Scope
📖 Local vs Global Variables
Local variable: A variable accessible only within the module in which it is declared. Good design uses local variables as it makes modules independent and reusable.
Global variable: A variable accessible from all modules.
5. Selection (Conditional Statements)
📖 What is Selection?
Selection is a control structure where a test decides if certain instructions are executed. When different actions are performed by an algorithm according to values of variables, conditional statements decide which action should be taken.
5.1 IF...THEN...ELSE...ENDIF
For an IF condition, the THEN path is followed if the condition is true and the ELSE path is followed if the condition is false. There may or may not be an ELSE path. The end of the statement is shown by ENDIF.
📝 Basic IF Statement Syntax
IF <condition> THEN
<statements if true>
ELSE
<statements if false>
ENDIF
Example 1: Simple IF (no ELSE)
DECLARE weight : REAL
INPUT "Enter your weight: " weight
IF weight < 20 THEN
OUTPUT "You are underweight"
ENDIF
Example 2: IF with ELSE
DECLARE age : INTEGER
INPUT "Enter your age in years: " age
IF age < 18 THEN
OUTPUT "You are a Child"
ELSE
OUTPUT "You are an Adult"
ENDIF
5.2 Nested IF Statements
When an IF statement contains another IF statement, we refer to these as nested IF statements. They allow for multiple conditions to be tested in sequence.
Example: Number Guessing Game
DECLARE SecretNum, Guess : INTEGER
SecretNum ← 30
INPUT "Enter your guess: ", Guess
IF Guess = SecretNum THEN
OUTPUT "Well done. You guessed the secret number!"
ELSE
IF Guess > SecretNum THEN
OUTPUT "Secret number is smaller"
ELSE
OUTPUT "Secret number is greater"
ENDIF
ENDIF
Example: Finding the Largest of Three Numbers
DECLARE num1, num2, num3 : INTEGER
OUTPUT "Enter three numbers"
INPUT num1, num2, num3
IF num1 > num2 AND num1 > num3 THEN
OUTPUT "The largest number is ", num1
ELSEIF num2 > num1 AND num2 > num3 THEN
OUTPUT "The largest number is ", num2
ELSE
OUTPUT "The largest number is ", num3
ENDIF
5.3 Logic Statements
Selection constructs use conditions that consist of at least one logic proposition. Logic propositions use relational (comparison) operators.
Operator
Meaning
Example
=
Equal to
age = 18
<>
Not equal to
status <> "active"
<
Less than
score < 50
>
Greater than
count > 0
<=
Less than or equal to
temp <= 100
>=
Greater than or equal to
age >= 18
AND
Both conditions must be true
age >= 13 AND age <= 19
OR
At least one condition true
day = "Sat" OR day = "Sun"
NOT
Reverses the condition
NOT(valid = TRUE)
💡 Exam Tip
When writing logic statements, use parentheses to group conditions clearly. Remember: AND has higher precedence than OR, so A OR B AND C is evaluated as A OR (B AND C).
5.4 CASE...OF...OTHERWISE...ENDCASE
When there are too many available routes in an algorithm, using multiple IF...THEN...ELSE statements becomes difficult to manage. The CASE statement is used for multiple specific options.
📝 CASE Statement Syntax
CASE <variable> OF
<value1> : <statements>
<value2> : <statements>
...
OTHERWISE : <statements>
ENDCASE
DECLARE Num1, Num2 : INTEGER
DECLARE Choice : CHAR
DECLARE Answer : REAL
OUTPUT "Enter two numbers"
INPUT Num1, Num2
OUTPUT "Enter 1 for +, 2 for -, 3 for *, 4 for /"
INPUT Choice
CASE Choice OF
'1' : Answer ← Num1 + Num2
'2' : Answer ← Num1 - Num2
'3' : Answer ← Num1 * Num2
'4' : Answer ← Num1 / Num2
OTHERWISE : OUTPUT "Please enter a valid choice"
ENDCASE
OUTPUT "Your result is ", Answer
⚠️ IF vs CASE - When to Use Each
IF...THEN...ELSE: Use for binary decisions (true/false conditions) or complex logical conditions
CASE...OF: Use when selecting from multiple specific values (like menu options, grades, days of week)
6. Iteration (Repetition/Loops)
📖 What is Iteration?
Iteration (also called repetition or looping) is a control structure where a group of statements is executed repeatedly - either a set number of times, or until a specific condition becomes true.
6.1 FOR...TO...NEXT Loop (Count-Controlled)
A FOR loop is an unconditional loop where the number of repetitions is set at the beginning. A variable is set up with a start value and an end value, then incremented in steps of one until the end value is reached.
📝 FOR Loop Syntax
FOR <counter> ← <start> TO <end>
<statements to repeat>
NEXT <counter>
Example 1: Simple Counter
FOR X ← 1 TO 5
Answer ← X * 3
OUTPUT Answer
NEXT X
// Output: 3, 6, 9, 12, 15
Example 2: Calculate Average of 15 Numbers
DECLARE Total, Count : INTEGER
DECLARE Avg : REAL
DECLARE Num : INTEGER
Total ← 0
FOR Count ← 1 TO 15
INPUT "Enter number: ", Num
Total ← Total + Num
NEXT Count
Avg ← Total / 15
OUTPUT "Average of 15 numbers is: ", Avg
Example 3: Find Largest Number (10 inputs)
DECLARE BiggestSoFar, NextNumber, Count : INTEGER
INPUT "Enter first number: ", BiggestSoFar
FOR Count ← 1 TO 9
INPUT "Enter next number: ", NextNumber
IF NextNumber > BiggestSoFar THEN
BiggestSoFar ← NextNumber
ENDIF
NEXT Count
OUTPUT "The largest number is: ", BiggestSoFar
6.2 WHILE...DO...ENDWHILE Loop (Pre-Condition)
A WHILE loop is used when we don't know how many times instructions need to be repeated. The condition is tested at the start of the loop. The loop repeats while the condition is TRUE and stops when it becomes FALSE.
📝 WHILE Loop Syntax
WHILE <condition> DO
<statements to repeat>
ENDWHILE
Example: Sum numbers while positive
DECLARE Total, Num : INTEGER
Total ← 0
Num ← 1
WHILE Num > 0 DO
OUTPUT "Please input a number greater than zero"
INPUT Num
Total ← Total + Num
ENDWHILE
OUTPUT "Total sum is: ", Total
6.3 REPEAT...UNTIL Loop (Post-Condition)
A REPEAT loop is used when we don't know how many times to repeat, but the loop must execute at least once. The condition is tested at the end of the loop. The loop repeats UNTIL the condition becomes TRUE.
📝 REPEAT Loop Syntax
REPEAT
<statements to repeat>
UNTIL <condition>
Example: Sum numbers until zero entered
DECLARE Total, Num : INTEGER
Total ← 0
REPEAT
INPUT "Enter a number to add: ", Num
Total ← Total + Num
UNTIL Num = 0
OUTPUT "Answer after addition is: ", Total
Feature
FOR-NEXT
WHILE-DO
REPEAT-UNTIL
Condition Check
None (count-based)
At the START
At the END
Minimum Iterations
Fixed number
May be zero
Always at least one
When to Use
Known count
Unknown, may be zero
Unknown, at least once
Loop Terminates
When count reached
When condition FALSE
When condition TRUE
6.4 Nested Loops
A nested loop is a construct where one loop contains another loop inside it. Each time round the outer loop, the inner loop completes all its iterations.
Example: Print a Grid of Symbols
Take as input two numbers and a symbol. Output a grid with the number of rows matching the first number and columns matching the second number.
DECLARE NumberOfRows, NumberOfColumns : INTEGER
DECLARE ColumnCount, RowCount : INTEGER
DECLARE Symbol : CHAR
INPUT "Enter number of rows: ", NumberOfRows
INPUT "Enter number of columns: ", NumberOfColumns
INPUT "Enter your symbol: ", Symbol
FOR RowCount ← 1 TO NumberOfRows
FOR ColumnCount ← 1 TO NumberOfColumns
OUTPUT Symbol // without moving to next line
NEXT ColumnCount
OUTPUT Newline // move to next line
NEXT RowCount
// Example: Input 3, 7, "&" produces:
// &&&&&&&
// &&&&&&&
// &&&&&&&
💡 Nested Loops Tip
The inner loop completes ALL its iterations before the outer loop moves to its next iteration. If outer runs 3 times and inner runs 7 times, the inner code executes 3 × 7 = 21 times total.
7. Stepwise Refinement
📖 What is Stepwise Refinement?
Stepwise refinement is the process of breaking down a complex problem into smaller, more manageable sub-problems in a logical order. Each sub-problem is refined step by step until it is simple enough to be solved with a single subroutine or module.
7.1 Relationship to Decomposition
Term
Definition
Decomposition
The general concept of breaking a problem down into smaller parts
Top-down Design
The strategy used to perform decomposition
Stepwise Refinement
The process used in top-down design to gradually refine each major task into simpler sub-tasks
7.2 Benefits of Stepwise Refinement
🌟 Benefits
Helps developers understand and organise the structure of a program
Makes testing and debugging easier through unit testing of individual subroutines
Encourages code reuse by breaking tasks into reusable components
Supports collaborative development, as tasks can be divided between team members
Each subroutine should be clear, focused on a single task, and simple enough to implement directly
Example: Calculating Student Grades
📝 Top-Level Task
Calculate grades for all students in all classes
📝 Stepwise Refinement
Step 1 – Calculate the grade for each assessment:
For each question: Mark the question
Store the mark
Sum the marks for all questions in the assessment
Step 2 – Calculate the average grade for each student:
Add together grades from all assessments
Divide by the number of assessments
Store the average
Step 3 – Repeat for each class:
For every student in the class: Perform Steps 1 and 2
8. Good Programming Practices
Features that make pseudocode or programs easier to read and understand are essential for producing quality code.
📖 What is a Transferable Skill?
Knowledge or experience of one programming language can be applied to another, unfamiliar, or unknown computer language. For example, it helps recognize control structures of unknown languages and makes learning new languages easier.
8.1 Features for Readable Code
📝 Good Programming Practices
Meaningful identifier names: Use names that describe what the variable stores (e.g., StudentAge instead of x)
Camel case: Use for identifier names (e.g., TotalScore, FirstName)
Capitalization of keywords: Makes keywords stand out (e.g., IF, THEN, ELSE, ENDIF)
Use of built-in functions: Makes code more efficient and readable
Use of constants: For values that don't change, makes code more maintainable
Proper indentation: Shows the structure and nesting of code
Blank lines and white space: Separates logical sections of code
Comments: Explain what the code does (preceded by // in pseudocode)
8.2 Purpose of Comments
⚠️ Why Add Comments?
Comments are used in programs or pseudocode to improve readability. They are not compiled or executed - they help the programmer understand the code. Comments are preceded by two forward slashes // in pseudocode.
Example: Well-Commented Code
// This program calculates the average of test scores
DECLARE Total, Count : INTEGER
DECLARE Score, Average : REAL
Total ← 0 // Initialize total to zero
// Get 5 scores from user
FOR Count ← 1 TO 5
OUTPUT "Enter score: "
INPUT Score
Total ← Total + Score // Add score to running total
NEXT Count
// Calculate and display average
Average ← Total / 5
OUTPUT "The average is: ", Average
💡 Exam Tip
If asked about making code more readable or maintainable, always mention: meaningful names, indentation, comments, and consistent style. These are key exam points!
9. Flowchart Symbols
Flowcharts are a visual tool that uses shapes to represent different functions to describe an algorithm. Standard symbols are used to ensure flowcharts can be understood universally.
Symbol
Name
Purpose
◯
Oval
Start/End of the algorithm
▱
Parallelogram
Input/Output operations
▭
Rectangle
Process/Calculation
◇
Diamond
Decision (Yes/No question)
→
Arrow
Flow direction/sequence
Example: Flowchart for checking if a number is even or odd
📝 Corresponding Pseudocode
INPUT Number
IF Number MOD 2 = 0 THEN
OUTPUT "Even"
ELSE
OUTPUT "Odd"
ENDIF
🧠 Memory Trick for Symbols
Oval = Overall beginning and end
Parallelogram = Parallel lines for data going in/out
Rectangle = Regular process (like a box)
Diamond = Decision has two paths (points left and right)
10. Exam-Style Questions
1. Define what is meant by an algorithm. Give two methods of expressing an algorithm before writing program code. [4 marks]
Answer:
An algorithm is a solution to a problem expressed as a sequence of defined steps
Method 1: Structured English - uses English phrases to describe each step
Method 2: Pseudocode - resembles a programming language without specific syntax
Method 3: Flowchart - graphical representation using standard symbols
Additional points for deeper understanding: Structured English is used in early planning stages; Pseudocode follows exam-board-defined syntax; Flowcharts use ovals for start/end, diamonds for decisions.
2. Explain the difference between a variable and a constant. Give an example of when you would use each. [4 marks]
Answer:
A variable is a memory location that stores data that CAN change while the program is running
A constant is a memory location that stores data that remains the SAME throughout execution
Variable example: A counter that increments in a loop (Count ← Count + 1)
Constant example: The value of Pi (3.14159) or maximum score (MAX_SCORE ← 100)
Additional points: Use of constants helps prevent accidental changes; Variables use DECLARE keyword, constants use CONSTANT keyword.
3. Write pseudocode to take 10 numbers as input and output their sum and average. [6 marks]
Answer:
DECLARE Total, Count, Num : INTEGER
DECLARE Average : REAL
Total ← 0
FOR Count ← 1 TO 10
OUTPUT "Enter a number: "
INPUT Num
Total ← Total + Num
NEXT Count
OUTPUT "Sum is: ", Total
Average ← Total / 10
OUTPUT "Average is: ", Average
Mark points: Initialize Total to 0 [1], Correct FOR loop [1], INPUT inside loop [1], Accumulation Total ← Total + Num [1], Calculate average [1], OUTPUT both values [1]
4. Explain when you would use a FOR loop versus a WHILE loop versus a REPEAT-UNTIL loop. [6 marks]
Answer:
FOR loop: Use when the number of iterations is known in advance (count-controlled)
WHILE loop: Use when the number of iterations is unknown and the loop may not execute at all (pre-condition check at start)
REPEAT-UNTIL loop: Use when the number of iterations is unknown but the loop must execute at least once (post-condition check at end)
FOR example: Processing exactly 10 students' marks
WHILE example: Reading data until a sentinel value, where the sentinel might be first value
REPEAT example: Validating user input - must ask at least once
5. Write pseudocode that takes three numbers as input and outputs the smallest number. [5 marks]
Answer:
DECLARE Num1, Num2, Num3 : INTEGER
OUTPUT "Enter three numbers"
INPUT Num1, Num2, Num3
IF Num1 < Num2 AND Num1 < Num3 THEN
OUTPUT "Smallest number is: ", Num1
ELSEIF Num2 < Num1 AND Num2 < Num3 THEN
OUTPUT "Smallest number is: ", Num2
ELSE
OUTPUT "Smallest number is: ", Num3
ENDIF
Mark points: Declare variables [1], Input three numbers [1], Correct IF structure [1], Correct conditions using AND [1], Output correct variable [1]
10. Exam-Style Questions (continued)
6. Write pseudocode for a program that asks the user to input a number and outputs whether the number is positive, negative, or zero. [5 marks]
Answer:
DECLARE Num : INTEGER
OUTPUT "Enter a number: "
INPUT Num
IF Num > 0 THEN
OUTPUT "The number is positive"
ELSEIF Num < 0 THEN
OUTPUT "The number is negative"
ELSE
OUTPUT "The number is zero"
ENDIF
Mark points: Declare variable [1], INPUT statement [1], IF for positive [1], ELSEIF for negative [1], ELSE for zero [1]
7. Describe what is meant by stepwise refinement. Explain how it relates to top-down design. [5 marks]
Answer:
Stepwise refinement is the process of breaking down a complex problem into smaller, more manageable sub-problems in a logical order
Each sub-problem is refined step by step until it is simple enough to be solved with a single subroutine
Top-down design is the strategy used to perform decomposition
Stepwise refinement is HOW top-down design is implemented - the process used to gradually refine each major task
Benefits: easier testing, debugging, code reuse, and collaborative development
Additional points: Each subroutine should be clear and focused on a single task; decomposition is the general concept of breaking problems down.
8. Write pseudocode to swap the values of two variables. Explain why a temporary variable is needed. [5 marks]
Answer:
DECLARE Value1, Value2, Temp : INTEGER
// Assume values are already assigned
Temp ← Value1 // Store Value1 temporarily
Value1 ← Value2 // Value1 now has Value2's content
Value2 ← Temp // Value2 now has original Value1's content
Explanation:
A temporary variable is needed because without it, the first value would be overwritten and lost
If we did Value1 ← Value2 first, we would lose the original Value1
Then Value2 ← Value1 would just copy the new Value1 (which is actually Value2) back to Value2
The temporary variable preserves the original value during the swap
9. Write pseudocode for a number guessing game where the computer has a secret number. The user guesses until correct, with hints of "higher" or "lower". [6 marks]
Answer:
DECLARE SecretNum, Guess : INTEGER
SecretNum ← 42 // Set secret number
REPEAT
OUTPUT "Enter your guess: "
INPUT Guess
IF Guess = SecretNum THEN
OUTPUT "Congratulations! You guessed correctly!"
ELSEIF Guess > SecretNum THEN
OUTPUT "Lower"
ELSE
OUTPUT "Higher"
ENDIF
UNTIL Guess = SecretNum
Mark points: Declare variables [1], Set secret number [1], REPEAT loop [1], INPUT guess [1], IF/ELSEIF structure [1], UNTIL condition [1]
10. A teacher uses a paper-based system to store marks for a class test. Write a detailed description of the algorithm needed to assign grades and output the average mark. [6 marks]
Answer:
Reference variables for Count of students and Total marks
Loop through all students (Count)
Input individual mark (in loop)
Compare mark with threshold/boundary values to determine grade (in loop)
Output the grade for a student (in loop)
Maintain a Total (and Count if required) (in loop)
Calculate average by dividing Total by Count and Output (after loop)
Additional detail: Could use CASE statement for grade boundaries; need to validate marks are in range 0-100; use meaningful variable names.
11. Glossary
Term
Definition
Algorithm
A solution to a problem expressed as a sequence of defined steps
Assignment
An instruction that places a value into a variable using the ← operator
Constant
A named memory location storing a value that cannot change during program execution
Decomposition
Breaking down a complex problem into smaller, more manageable sub-problems
Flowchart
A graphical representation of an algorithm using standard symbols
Identifier
The unique name given to a variable, constant, array, procedure, or function
Iteration
Repeating a block of code multiple times (also called looping or repetition)
Local Variable
A variable accessible only within the module where it is declared
Global Variable
A variable accessible from all modules in the program
Nested IF
An IF statement contained within another IF statement
Pseudocode
A method of describing an algorithm using keywords and identifiers without following a specific programming language syntax
Selection
A control structure where a condition determines which instructions are executed
Sequence
Executing programming statements one after another in order
Stepwise Refinement
The process of breaking down a problem into smaller steps gradually until each is simple enough to solve
Structured English
A method of describing algorithms using English phrases and programming logic structures
Top-down Design
A design strategy that starts with the overall problem and breaks it down into smaller components
Variable
A named memory location storing a value that can change during program execution
12. Exam Success Tips
💡 Loop Selection - Key Reminders
FOR loop: Use when you know EXACTLY how many times to repeat
WHILE loop: Use when you might not execute at all (check at START)
REPEAT-UNTIL: Use when you must execute AT LEAST once (check at END)
Remember: WHILE continues while TRUE, REPEAT continues until TRUE
💡 IF vs CASE - When to Use
IF-THEN-ELSE: For binary decisions or complex logical conditions
CASE-OF: For selecting from multiple specific values (like grades: A, B, C, D, F)
Use ELSEIF for multiple IF conditions in sequence
Always end IF statements with ENDIF and CASE statements with ENDCASE
🧠 Memory Trick: Loop Condition Logic
WHILE = "While it's TRUE, keep going"
REPEAT = "Repeat UNTIL it becomes TRUE"
WHILE is like asking "Can I start?" before entering a room
REPEAT is like "Do the task, then check if you should stop"
❌ Common Mistakes to Avoid
Forgetting to initialize variables before a loop (Total ← 0)
Using = for assignment instead of ←
Forgetting ENDIF or ENDCASE at the end of statements
Confusing WHILE (condition is TRUE to continue) with REPEAT-UNTIL (condition is TRUE to stop)
Not using meaningful variable names in pseudocode
Forgetting NEXT at the end of FOR loops
💡 Identifier Naming Rules
Must start with a letter (not a number)
Can contain letters, digits, and underscores only
No spaces allowed (use CamelCase or underscores)
Cannot be a keyword (like IF, THEN, ELSE)
Should be meaningful and describe what it stores
12. Exam Success Tips (continued)
💡 Answer Structure Tips
For "describe" questions: Give step-by-step details of how something works
For "explain" questions: Give reasons WHY something happens or differs
For "compare" questions: Use a table format and mention BOTH items for each point
For "write pseudocode" questions: Include DECLARE statements, proper keywords, and indentation
Always use technical terms: assignment, iteration, selection, condition, identifier
Mark allocations give hints: [4 marks] = 4 distinct points needed
🌟 Quick Reference Table
Topic
Key Point
Variable
Named memory location, value can change, use DECLARE
Constant
Named memory location, value fixed, use CONSTANT
Assignment
Use ← operator, variable on left, expression on right
Selection
IF-THEN-ELSE for binary, CASE-OF for multiple values
Iteration
FOR (known count), WHILE (pre-test), REPEAT (post-test)
Stepwise Refinement
Break problem down gradually until each step is simple
⚠️ Pseudocode Standards to Follow
Keywords in UPPERCASE: IF, THEN, ELSE, ENDIF, FOR, TO, NEXT, WHILE, DO, ENDWHILE, REPEAT, UNTIL, CASE, OF, OTHERWISE, ENDCASE
Variables in lowercase or CamelCase: count, TotalScore, StudentName
Strings in quotes: "Hello World"
Comments with //: // This is a comment
Indentation: Indent code inside IF, FOR, WHILE, REPEAT blocks