Pseudocode: Writing Algorithm Steps in English

Pseudocode: Writing Algorithm Steps in English

Master the art of writing clear, structured algorithms before coding - essential for CSEC IT success!

1

What is Pseudocode? (The "False" Code)

Definition

A language-independent way of representing an algorithm using structured English. It's like writing instructions that both humans and computers can understand.

The Goal

To focus on the logic of the solution rather than the punctuation (commas, semicolons, etc.) of a programming language.

Pseudocode vs. Pure English

Why "Add the numbers" is too vague, while "Sum ← Num1 + Num2" is structured and precise.

The Code Translator

Drag the slider to transform plain English into structured Pseudocode!

Plain English:
"First, ask the user to type in two numbers. Then add those numbers together. Finally, show the result on the screen."

Plain English Structured Pseudocode

Pseudocode:
Move the slider to see the transformation...

2

The Essential Keywords

Input/Output Keywords

  • READ, GET, PROMPT - For getting input from the user
  • PRINT, DISPLAY, OUTPUT - For showing results

Processing Keywords

  • COMPUTE, CALCULATE, SET - For calculations and assignments
  • INCREMENT, DECREMENT - For changing values

The Assignment Operator

Using the arrow (←) or equal sign (=) to store values in variables:

Total ← Price * Quantity
Average = Sum / Count
Keyword Drag-and-Drop

Drag the correct Pseudocode keyword to match each action!

Show the result to the user
Ask for the user's age
Find the average of three numbers
Store the price in a variable
PRINT
READ
CALCULATE
SET
IF
WHILE
3

Representing Control Structures

Sequence

Listing steps in logical order (1, 2, 3...). The simplest structure.

Selection (If-Then-Else)

IF Grade >= 50 THEN
    PRINT "Pass"
ELSE
    PRINT "Fail"
ENDIF

Iteration (Loops)

// Count-controlled loop
FOR Counter ← 1 TO 10
    PRINT Counter
ENDFOR

// Condition-controlled loop
WHILE Counter <= 10
    PRINT Counter
    Counter ← Counter + 1
ENDWHILE
Logic Path Highlighter

Click a condition (True or False) to see the path the computer takes through the code!

Condition: TRUE
Condition: FALSE
1
IF Score >= 50 THEN
2
    PRINT "You passed!"
3
ELSE
4
    PRINT "Try again"
5
ENDIF
4

Best Practices for CSEC Pseudocode

Indentation

"Pushing in" lines inside IF or LOOP structures makes code readable for examiners. It shows the structure visually.

Naming Consistency

Ensure variable names in your Pseudocode match your IPO chart. Use meaningful names like "TotalPrice" not "X".

End Statements

Always use ENDIF, ENDFOR, and ENDWHILE to "close the box" of your control structures.

The Indentation Fixer

Click the lines that should be indented to make the structure clear!

Flat (Poor) Pseudocode:

1
READ Number1, Number2
2
IF Number1 > Number2 THEN
3
PRINT "First number is larger"
4
ELSE
5
PRINT "Second number is larger or equal"
6
ENDIF
Properly Indented Preview: READ Number1, Number2 IF Number1 > Number2 THEN PRINT "First number is larger" ELSE PRINT "Second number is larger or equal" ENDIF
5

From Flowchart to Pseudocode

Mapping Symbols to Syntax

  • Parallelogram (I/O) → READ / PRINT
  • Rectangle (Process) → SET / CALCULATE
  • Diamond (Decision) → IF-THEN-ELSE
  • Oval (Start/End) → START / STOP
Symbol to Syntax

Click a flowchart symbol to see the corresponding Pseudocode!

READ Input
CALCULATE
IF
PRINT Result

Pseudocode Equivalent:

READ Number1, Number2
Total ← Number1 + Number2
IF Total > 100 THEN
    PRINT "Large total"
ENDIF
PRINT "The total is: ", Total
Click a flowchart symbol to see its Pseudocode
6

CSEC SBA Prep: Writing Your Algorithm

Step-by-Step Example

Walkthrough of writing pseudocode for a common SBA task: calculating total cost with discount and tax.

Task: Write pseudocode to calculate the final price of an item after applying a discount and sales tax.

1
Identify inputs needed: Original Price, Discount Percentage, Tax Rate
2
Plan the calculations: Discount Amount, Price After Discount, Tax Amount, Final Price
3
Write the pseudocode with proper structure:
// Calculate final price with discount and tax

START
READ OriginalPrice, DiscountPercent, TaxRate

DiscountAmount ← OriginalPrice * (DiscountPercent / 100)
PriceAfterDiscount ← OriginalPrice - DiscountAmount
TaxAmount ← PriceAfterDiscount * (TaxRate / 100)
FinalPrice ← PriceAfterDiscount + TaxAmount

PRINT "Original Price: $", OriginalPrice
PRINT "Discount: $", DiscountAmount
PRINT "Final Price: $", FinalPrice
STOP

The Trace Table Link

Your pseudocode must be clear enough for you to test it with a Trace Table later. Each line should represent one logical step.

7

Knowledge Check: The Pseudocode Editor

Bug Hunt

Find and click the 3 errors in this pseudocode!

READ Student Name
IF Age >= 18 THEN
    PRINT "Adult"
ELSE
    PRINT "Minor"
// Missing ENDIF
Total Cost = Price * Quantity

Short Answer

"Why is it better to write pseudocode before typing code into a programming compiler?"

8

Pseudocode Syntax Guide

Comparison of common CSEC pseudocode keywords with their equivalents in Pascal programming language.

Purpose Pseudocode Keyword Pascal Equivalent
Input from user READ, GET readln(variable);
Output to screen PRINT, DISPLAY writeln('text');
Assignment ← or = variable := value;
Condition (if) IF condition THEN if condition then
Loop (count) FOR variable ← start TO end for variable := start to end do
Loop (condition) WHILE condition while condition do
End if statement ENDIF end;
End loop ENDFOR, ENDWHILE end;

Key Takeaway: Pseudocode focuses on logic, Pascal focuses on syntax. Write pseudocode first, then translate to Pascal!

Scroll to Top