Program Documentation: Internal and External Documentation

A program that works is good – but a program that works and is easy for others to understand is much better. Documentation is the written explanation that goes with a program. In this post you will learn the two types: internal and external documentation.

Build on what you learned in Forms 1–3

These Lower School ICT posts cover the basics of this topic:

In this post:

  • Why document a program?
  • Internal documentation
  • External documentation
  • A well-documented program in Python and C

Why document a program?

  • Other programmers (or you, months later!) can understand and maintain the program.
  • Users can learn how to install and use the program.
  • Errors are easier to find and fix.

Internal documentation

Internal documentation is written inside the source code. It includes:

  • Comments – notes that the translator ignores. In Python they start with #; in C they go between /* and */ (or after //).
  • A header comment at the top: program name, author, date and purpose.
  • Meaningful variable names such as rate_per_km instead of r.
  • Indentation and white space so the structure (IFs and loops) is easy to see.

External documentation

External documentation is separate from the code. It includes:

  • User documentation (user manual or help files) – tells users how to install, start and use the program, with screenshots and troubleshooting tips.
  • Technical documentation – for programmers: the algorithms, flowcharts, IPO charts, data types used and test results.

A well-documented program

Python

# ------------------------------------------------------------
# Program:  Taxi fare calculator
# Author:   A. Student
# Date:     16 October 2026
# Purpose:  Works out a taxi fare from the distance travelled.
#           Fare = base fee + (rate per km x distance)
# ------------------------------------------------------------

BASE_FEE = 5.00       # fixed charge for every trip ($)
RATE_PER_KM = 2.50    # charge for each kilometre ($)

# Input: distance in kilometres
distance = float(input("Enter distance travelled (km): "))

# Process: calculate the fare
fare = BASE_FEE + RATE_PER_KM * distance

# Output: display the fare to 2 decimal places
print("Fare: $" + format(fare, ".2f"))

C

/* ------------------------------------------------------------
   Program:  Taxi fare calculator
   Author:   A. Student
   Date:     16 October 2026
   Purpose:  Works out a taxi fare from the distance travelled.
             Fare = base fee + (rate per km x distance)
   ------------------------------------------------------------ */
#include <stdio.h>

#define BASE_FEE 5.00      /* fixed charge for every trip ($) */
#define RATE_PER_KM 2.50   /* charge for each kilometre ($)   */

int main(void)
{
    float distance, fare;

    /* Input: distance in kilometres */
    printf("Enter distance travelled (km): ");
    scanf("%f", &distance);

    /* Process: calculate the fare */
    fare = BASE_FEE + RATE_PER_KM * distance;

    /* Output: display the fare to 2 decimal places */
    printf("Fare: $%.2f\n", fare);
    return 0;
}

Sample run with 12 km: Fare: $35.00. Notice the header comment, the comments for input, processing and output, the named constants and the meaningful variable names.

How large software teams organise and document code so that many people can work on it.

Video: Software Engineering: Crash Course Computer Science #16 – https://www.youtube.com/watch?v=O753uuutqH8

Try it: Internal or external documentation?

Classify each item.

A comment explaining what a loop does
A printed user manual for a school library program
Using the variable name total_sales instead of ts
An online help page with screenshots
A header comment with the author and date
A flowchart of the program kept in a design report

Paper 1 practice (multiple choice)

Choose the best answer for each question. Try them all before you check.

1. Comments written inside the source code are an example of
(A) external documentation
(B) internal documentation
(C) a user manual
(D) test data

2. Which is an example of external documentation?
(A) Indentation
(B) A user manual
(C) Meaningful variable names
(D) A comment

3. In Python, a comment begins with
(A) //
(B) /*
(C) #
(D) REM

4. ONE purpose of program documentation is to
(A) make the program run faster
(B) help others understand and maintain the program
(C) remove syntax errors automatically
(D) translate the program

5. Which variable name is the MOST meaningful?
(A) x
(B) tp
(C) total_price
(D) a1

Show answers

1. B
2. B
3. C
4. B
5. C

Paper 2 practice (structured question)

A programmer has written a program to calculate the monthly salaries of workers at a factory in San Fernando. The program will be used by the payroll clerk and updated by other programmers in the future.

(a) Distinguish between internal and external documentation. (2 marks)

(b) Give TWO examples of internal documentation the programmer should include. (2 marks)

(c) State TWO items that should be included in the user manual for the payroll clerk. (2 marks)

(d) Explain why documentation is important for the programmers who will update the program in the future. (2 marks)

Total: 8 marks

Show answers

(a) Internal documentation is written within the source code (1 mark); external documentation is separate from the code, e.g. manuals (1 mark).

(b) Any two (1 mark each):
• comments
• a header comment (name, author, date, purpose)
• meaningful variable names
• indentation/white space

(c) Any two (1 mark each):
• how to install/start the program
• how to enter workers’ data
• how to print payslips/reports
• error messages and troubleshooting
• system requirements

(d) It helps them understand what each part of the program does (1 mark), so they can make changes and fix errors more quickly and safely (1 mark).

Next: CSEC Information Technology Notes (course page)

Syllabus link: This post is relevant to the CSEC® Information Technology Syllabus (CXC 30/G/SYLL 17), Section 8: Program Implementation, Specific Objective 6 (“effectively document programs”).

Attributions to media used in this post:

No third-party images are used in this post. Embedded videos are credited on YouTube to their channels.

Updates

2026/10/16

– Author name in example programs changed to a generic student name.
– Syntax highlighting added to code examples.

© 2026 Vedesh Kungebeharry. All rights reserved.

Declaring Variables and Translating Algorithms into Python and C

This is where it all comes together: you take an algorithm written in pseudocode and translate it into a real program. We will do every example in Python and C side by side, so you can see how each pseudocode statement becomes code.

Build on what you learned in Forms 1–3

These Lower School ICT posts cover the basics of this topic:

In this post:

  • Declaring variables and constants
  • A pseudocode-to-code translation table
  • Worked example 1: sequence (average of 3 scores)
  • Worked example 2: selection inside a WHILE loop (counting passes)

Declaring variables and constants

To declare a variable means to give it a name and (in many languages) a data type, so the computer sets aside memory for it.

  • In C you must declare each variable with its type before using it: int (integer), float (real), char (character), char name[20] (string), bool (Boolean, with #include <stdbool.h>). Constants can be made with #define PASS_MARK 50 or const int PASS_MARK = 50;.
  • In Python a variable is created when you first assign a value to it, and Python works out the type: age = 15 (int), price = 12.5 (float), name = "Kezia" (str), paid = True (bool). Constants are written in CAPITALS by convention: PASS_MARK = 50.

Python

# Declaring (creating) variables and a constant in Python
SCHOOL_NAME = "Island Secondary"   # constant (by convention, CAPITALS)
age = 15                            # integer
height = 1.62                       # real (float)
grade = 'A'                         # character (a string of length 1)
name = "Kezia"                      # string
is_prefect = True                   # Boolean
print(name, "is", age, "years old and got grade", grade)
print("Height:", height, "m  Prefect:", is_prefect, " School:", SCHOOL_NAME)

C

/* Declaring variables and a constant in C */
#include <stdio.h>
#include <stdbool.h>

#define SCHOOL_NAME "Island Secondary"   /* constant */

int main(void)
{
    int age = 15;              /* integer */
    float height = 1.62;       /* real */
    char grade = 'A';          /* character */
    char name[20] = "Kezia";   /* string (array of characters) */
    bool is_prefect = true;    /* Boolean (1 = true, 0 = false) */

    printf("%s is %d years old and got grade %c\n", name, age, grade);
    printf("Height: %.2f m  Prefect: %d  School: %s\n", height, is_prefect, SCHOOL_NAME);
    return 0;
}

Translation table

PseudocodePythonC
READ ageage = int(input())scanf(“%d”, &age);
READ priceprice = float(input())scanf(“%f”, &price);
PRINT “Total: “, totalprint(“Total:”, total)printf(“Total: %.2f\n”, total);
total ← 0total = 0total = 0;
IF x > 5 THEN … ELSE … ENDIFif x > 5:
    …
else:
    …
if (x > 5) { … } else { … }
FOR i ← 1 TO 10 DO … ENDFORfor i in range(1, 11):for (i = 1; i <= 10; i++) { … }
WHILE x <> -1 DO … ENDWHILEwhile x != -1:while (x != -1) { … }
a AND b, a OR b, NOT aa and b, a or b, not aa && b, a || b, !a
x MOD y, x DIV yx % y, x // yx % y, x / y (both integers)

Remember: Python uses indentation (spaces) to show which lines belong inside an IF or a loop; C uses curly braces { } and ends each statement with a semicolon.

Worked example 1: average of three scores (sequence)

Pseudocode

START
    READ score1, score2, score3
    average ← (score1 + score2 + score3) / 3
    PRINT "The average is ", average
STOP

Python

# Find the average of three test scores
score1 = float(input("Enter score 1: "))
score2 = float(input("Enter score 2: "))
score3 = float(input("Enter score 3: "))
average = (score1 + score2 + score3) / 3
print("The average is", format(average, ".2f"))

C

/* Find the average of three test scores */
#include <stdio.h>

int main(void)
{
    float score1, score2, score3, average;

    printf("Enter score 1: ");
    scanf("%f", &score1);
    printf("Enter score 2: ");
    scanf("%f", &score2);
    printf("Enter score 3: ");
    scanf("%f", &score3);

    average = (score1 + score2 + score3) / 3;
    printf("The average is %.2f\n", average);
    return 0;
}

Sample run: scores 60, 70 and 85 → The average is 71.67.

Worked example 2: counting passes (WHILE loop with selection)

Pseudocode

PASS_MARK ← 50
count ← 0
passed ← 0
READ mark
WHILE mark <> -1 DO
    count ← count + 1
    IF mark >= PASS_MARK THEN
        PRINT "Pass"
        passed ← passed + 1
    ELSE
        PRINT "Fail"
    ENDIF
    READ mark
ENDWHILE
PRINT passed, " out of ", count, " students passed"

Python

# Count how many students passed (mark of 50 or more).
# Enter -1 to stop.
PASS_MARK = 50
count = 0
passed = 0
mark = int(input("Enter mark (-1 to stop): "))
while mark != -1:
    count = count + 1
    if mark >= PASS_MARK:
        print("Pass")
        passed = passed + 1
    else:
        print("Fail")
    mark = int(input("Enter mark (-1 to stop): "))
print(passed, "out of", count, "students passed")

C

/* Count how many students passed (mark of 50 or more).
   Enter -1 to stop. */
#include <stdio.h>

#define PASS_MARK 50

int main(void)
{
    int mark, count = 0, passed = 0;

    printf("Enter mark (-1 to stop): ");
    scanf("%d", &mark);
    while (mark != -1)
    {
        count = count + 1;
        if (mark >= PASS_MARK)
        {
            printf("Pass\n");
            passed = passed + 1;
        }
        else
        {
            printf("Fail\n");
        }
        printf("Enter mark (-1 to stop): ");
        scanf("%d", &mark);
    }
    printf("%d out of %d students passed\n", passed, count);
    return 0;
}

Sample run with 72, 45, 50 then −1: Pass, Fail, Pass, then 2 out of 3 students passed. Notice that the mark of 50 (a boundary value) correctly gives “Pass”.

Try running these yourself. You can install Python (IDLE or Thonny) and a C compiler such as gcc or Code::Blocks, or use an online editor.

Try it: Pseudocode to code

Choose the correct Python or C statement for each pseudocode line.

READ age (Python)
PRINT total (C, total is an integer)
IF mark >= 50 THEN (Python)
WHILE n <> 0 DO (C)
FOR i ← 1 TO 5 DO (Python)
Declare a real variable called price (C)

Related

Related: Demo: Constants, Variables and Datatypes.; Python Example: Indefinite prompting to determine the corresponding grade for a given mark

Paper 1 practice (multiple choice)

Choose the best answer for each question. Try them all before you check.

1. Which C statement declares an integer variable called count?
(A) count int;
(B) int count;
(C) integer count
(D) declare count

2. In Python, which statement reads a whole number from the user?
(A) num = input(int)
(B) num = int(input())
(C) scanf(num)
(D) READ num

3. The pseudocode operator <> is written in Python and C as
(A) =
(B) ==
(C) !=
(D) <>

4. Which C data type is used for a real number such as 12.75?
(A) int
(B) char
(C) float
(D) bool

5. In Python, the lines inside an if statement are shown by
(A) curly braces
(B) semicolons
(C) indentation
(D) ENDIF

Show answers

1. B
2. B
3. C
4. C
5. C

Paper 2 practice (structured question)

The following pseudocode finds the total cost of tickets for a school concert:

READ num_tickets
cost ← num_tickets * 40
IF num_tickets >= 10 THEN
    cost ← cost - 50
ENDIF
PRINT cost

(a) Write a declaration, in a high-level language of your choice, for:

(i) the variable num_tickets (1 mark)

(ii) the variable cost (1 mark)

(b) Explain why the ticket price of $40 could be declared as a constant. (1 mark)

(c) Translate the pseudocode into a high-level language of your choice. (5 marks)

(d) State the output when num_tickets is 12. (2 marks)

Total: 10 marks

Show answers

(a)

(i) Int num_tickets; (in C) or num_tickets = 0 (in Python) (1 mark)

(ii) Int cost; or float cost; (in C) or cost = 0 (in Python) (1 mark)

(b) The price does not change while the program runs, so storing it as a constant makes the program easier to read and update (1 mark).

(c)
• Reading num_tickets correctly, e.g. num_tickets = int(input()) or scanf("%d", &num_tickets); (1 mark)
• cost = num_tickets * 40 (1 mark)
• if num_tickets >= 10 with correct syntax (1 mark)
• cost = cost - 50 inside the if (1 mark)
• print(cost) or printf("%d", cost); (1 mark)

(d) 12 × 40 = 480 (1 mark); 480 − 50 = 430, so 430 is printed (1 mark).

Next: Program Documentation: Internal and External Documentation

Syllabus link: This post is relevant to the CSEC® Information Technology Syllabus (CXC 30/G/SYLL 17), Section 8: Program Implementation, Specific Objectives 4 and 5 (“declare variables and constants using elementary data types” and “translate algorithmic statements into high-level language syntax”).

Attributions to media used in this post:

No third-party images are used in this post. Embedded videos are credited on YouTube to their channels.

Updates

2026/10/16

– Syntax highlighting added to code examples.

© 2026 Vedesh Kungebeharry. All rights reserved.

Program Errors, Testing and Debugging: Syntax, Logic and Runtime Errors

Almost no program works perfectly the first time – not even for professional programmers! In this post you will learn the three types of program errors, how to choose good test data, and some techniques for debugging (finding and fixing errors).

Build on what you learned in Forms 1–3

These Lower School ICT posts cover the basics of this topic:

In this post:

  • Syntax errors
  • Logic errors
  • Runtime errors
  • Test data: normal, boundary and erroneous
  • Debugging techniques
The famous “first computer bug”: a moth found trapped in the Harvard Mark II computer in 1947 and taped into the log book. Finding and fixing errors is still called debugging.
The famous “first computer bug”: a moth found trapped in the Harvard Mark II computer in 1947 and taped into the log book. Finding and fixing errors is still called debugging.

Image source: File:H96566k.jpg

Syntax errors

A syntax error happens when the rules (grammar) of the programming language are broken – for example a missing bracket, a missing semicolon or a misspelt keyword like pritn. The translator finds these errors, and the program will not run until they are fixed.

Python

print("Hello, Trinidad!"    # missing closing bracket

C

#include <stdio.h>

int main(void)
{
    printf("Hello, Trinidad!\n")    /* missing semicolon */
    return 0;
}

Python reports SyntaxError: '(' was never closed. The C compiler (gcc) reports error: expected ';' before 'return'.

Logic errors

A logic error is a mistake in the design of the program. The program runs, but gives the wrong result. The computer cannot spot it for you – you find it by testing and comparing with the expected answer (a trace table helps!).

Python

# Logic error: the brackets are missing, so only score3 is divided by 3
score1 = 60
score2 = 70
score3 = 80
average = score1 + score2 + score3 / 3     # WRONG - gives 156.67
print("Average:", average)
average = (score1 + score2 + score3) / 3   # CORRECT - gives 70.0
print("Average:", average)

C

/* Logic error: the brackets are missing, so only score3 is divided by 3 */
#include <stdio.h>

int main(void)
{
    float score1 = 60, score2 = 70, score3 = 80, average;

    average = score1 + score2 + score3 / 3;     /* WRONG - gives 156.67 */
    printf("Average: %.2f\n", average);
    average = (score1 + score2 + score3) / 3;   /* CORRECT - gives 70.00 */
    printf("Average: %.2f\n", average);
    return 0;
}

Both programs print 156.67 for the wrong line and 70 for the correct line. Other common logic errors: using > instead of >=, or a loop that runs one time too many.

Runtime errors

A runtime error happens while the program is running and usually makes it crash. Examples: dividing by zero, trying to open a file that does not exist, or a user typing letters when a number was expected.

Python program with a runtime error

# Runtime error: dividing by zero crashes the program while it runs
total_marks = int(input("Total marks: "))
num_students = int(input("Number of students: "))
print("Class average:", total_marks / num_students)

If the user enters 0 students, Python stops with ZeroDivisionError: division by zero. A good programmer checks the input first:

Python

# Fixed: check the value before dividing
total_marks = int(input("Total marks: "))
num_students = int(input("Number of students: "))
if num_students > 0:
    print("Class average:", total_marks / num_students)
else:
    print("Number of students must be more than 0")

C

/* Fixed: check the value before dividing */
#include <stdio.h>

int main(void)
{
    int total_marks, num_students;

    printf("Total marks: ");
    scanf("%d", &total_marks);
    printf("Number of students: ");
    scanf("%d", &num_students);
    if (num_students > 0)
        printf("Class average: %.2f\n", (float) total_marks / num_students);
    else
        printf("Number of students must be more than 0\n");
    return 0;
}

Sample run with 300 and 0: Number of students must be more than 0.

Test data

Type of test dataMeaningExample for marks 0–100 with pass mark 50
NormalTypical, valid values the program should accept35, 72, 88
Boundary (extreme)Values at the edges of the valid range0, 49, 50, 100
Erroneous (abnormal)Invalid values the program should reject−5, 150, “abc”

Debugging techniques

  • Read the error messages – they usually give the line number.
  • Dry run with a trace table – follow the code by hand to see where values go wrong.
  • Print statements – temporarily display the values of variables at different points.
  • Use a debugger – step through the program line by line and watch the variables (IDEs such as Thonny or Code::Blocks have this).
  • Test small parts one at a time.

Try it: Error-type sorter

Decide whether each problem is a syntax, logic or runtime error.

The keyword print is typed as prnt
The program uses > 50 instead of >= 50, so a mark of 50 shows “Fail”
The program crashes when the user enters 0 as the number to divide by
A closing bracket is missing at the end of a line
The total is calculated as price + quantity instead of price * quantity
The program crashes because a file it must open has been deleted

Related

Related: How to Approach a Dry run using test data and trace tables to uncover errors in your algorithm

Paper 1 practice (multiple choice)

Choose the best answer for each question. Try them all before you check.

1. A missing semicolon in a C program is an example of a
(A) logic error
(B) syntax error
(C) runtime error
(D) linking error

2. A program runs but displays the wrong total. This is MOST likely a
(A) syntax error
(B) logic error
(C) runtime error
(D) compiler error

3. Dividing a number by zero while a program is running causes a
(A) syntax error
(B) logic error
(C) runtime error
(D) typing error

4. For a program that accepts ages 13 to 19, which is BOUNDARY test data?
(A) 15
(B) 13
(C) 25
(D) −2

5. The process of finding and correcting errors in a program is called
(A) compiling
(B) linking
(C) debugging
(D) documenting

Show answers

1. B
2. B
3. C
4. B
5. C

Paper 2 practice (structured question)

A program is written to accept a student’s mark from 0 to 100 and display “Pass” for marks of 50 and over.

(a) Distinguish between a syntax error and a logic error. (2 marks)

(b) Give ONE example of:

(i) a runtime error (1 mark)

(ii) a logic error that could occur in this program (1 mark)

(c) Suggest ONE value of EACH type of test data for this program:

(i) normal (1 mark)

(ii) boundary (1 mark)

(iii) erroneous (1 mark)

(d) Describe TWO debugging techniques a programmer could use. (2 marks)

Total: 9 marks

Show answers

(a) A syntax error breaks the rules of the programming language and is found by the translator (1 mark); a logic error lets the program run but gives incorrect results (1 mark).

(b)

(i) The program crashes when the user types letters instead of a number (1 mark)

(ii) Using > 50 instead of >= 50 so a mark of 50 shows “Fail” (1 mark)

(c)

(i) A typical valid mark such as 72 (1 mark)

(ii) 0, 49, 50 or 100 (1 mark)

(iii) Any value below 0 or above 100, e.g. 150 (1 mark)

(d) Any two (1 mark each):
• dry run with a trace table
• adding print statements to display variable values
• using a debugger to step through the code
• reading error messages and line numbers
• testing small parts separately

Next: Declaring Variables and Translating Algorithms into Python and C

Syllabus link: This post is relevant to the CSEC® Information Technology Syllabus (CXC 30/G/SYLL 17), Section 8: Program Implementation, Specific Objective 3 (“perform checks and tests on programs to verify correctness”).

Attributions to media used in this post:

  • H96566k.jpg – Courtesy of the Naval Surface Warfare Center, Dahlgren, VA., 1988. – Public domain (via Wikimedia Commons)

Updates

2026/10/16

– Syntax highlighting added to code examples.

© 2026 Vedesh Kungebeharry. All rights reserved.

Low-Level vs High-Level Languages and the Steps in Implementing a Program

You now know how to design an algorithm. Section 8 is about turning it into a working program. First we look at the different types of programming languages, and then at the steps from typing the code to running it.

Build on what you learned in Forms 1–3

These Lower School ICT posts cover the basics of this topic:

In this post:

  • Low-level languages: machine language and assembly language
  • High-level languages
  • Translators: compilers, interpreters and assemblers
  • The steps in implementing a program

Low-level languages

A low-level language is close to what the computer’s hardware understands.

  • Machine language – instructions written in binary (0s and 1s), e.g. 10110000 01100001. The CPU can run it directly, but it is very hard for people to read and write, and it is different for each type of processor.
  • Assembly language – uses short codes called mnemonics, e.g. MOV, ADD, LOAD. It is easier than binary but still tied to one type of processor, and must be changed into machine code by an assembler.
A punched card from a Fortran program. Early programmers typed each line of code onto a card like this, and the computer read the holes.
A punched card from a Fortran program. Early programmers typed each line of code onto a card like this, and the computer read the holes.

Image source: File:FortranCardPROJ039.agr.jpg

High-level languages

A high-level language uses English-like words and normal maths symbols, so it is easier to learn, read and fix. Examples: Python, C, Pascal, Java, Visual Basic. The same program can run on different types of computers (it is portable), but it must be translated into machine code first.

Low-levelHigh-level
Close to machine code; hard for people to understandEnglish-like; easier to read and write
Machine-dependent (works on one type of processor)Portable (can run on different computers)
Runs very fast and uses little memoryMust be translated; may run slightly slower
Slow to write and hard to debugFaster to write and easier to debug

Here is the same tiny program in two high-level languages:

Python

print("Hello, Caribbean!")

C

#include <stdio.h>

int main(void)
{
    printf("Hello, Caribbean!\n");
    return 0;
}

Both print Hello, Caribbean! – C needs a little more structure (the main function, semicolons and return 0).

How programming moved from machine code to assembly language and then to high-level languages, including the work of Grace Hopper.

Video: The First Programming Languages: Crash Course Computer Science #11 – https://www.youtube.com/watch?v=RU1u-js7db8

Translators

  • Compiler – translates the whole high-level program into machine code (object code) before it runs; the result can then be run many times. C uses a compiler.
  • Interpreter – translates and runs the program one line at a time, and stops at the first error it meets. Python normally uses an interpreter.
  • Assembler – translates assembly language into machine code.

Steps in implementing a program

  1. Create the source code – type the program in a high-level language using an editor or IDE (e.g. IDLE, Thonny, VS Code, Code::Blocks). The program you type is called source code.
  2. Translate (compile) – the compiler checks for syntax errors and converts the source code into object code (machine code).
  3. Link – the linker joins the object code with any library code it uses (e.g. the code for printf) to make one executable file.
  4. Execute (run) – the computer runs the executable program, and you test it with test data.
  5. Maintain – after the program is in use, it is corrected, updated and improved (e.g. when the VAT rate changes or users ask for a new feature).

For example, to run the C program above in a terminal you type gcc hello.c -o hello (compile and link) and then ./hello (execute).

Try it: Which step or term is it?

Choose the correct answer for each description.

Typing the program in Python or C
Converting the whole program into object code
Joining object code with library code to make an executable file
Running the program with test data
Updating the program a year later to add a new feature
Translates and runs one line at a time
Language made of mnemonics like ADD and MOV

Related

Related: The Real Context of Program Implementation & Programming languages – 2025-10-08_09-30-23

Paper 1 practice (multiple choice)

Choose the best answer for each question. Try them all before you check.

1. Which of the following is a high-level language?
(A) Machine code
(B) Assembly language
(C) Python
(D) Binary

2. A program that translates the whole of a source program into machine code before it is run is
(A) an interpreter
(B) a compiler
(C) an assembler
(D) a linker

3. Assembly language uses
(A) English sentences
(B) mnemonics such as ADD and MOV
(C) only 0s and 1s
(D) pictures

4. Which step joins object code with library routines to make an executable program?
(A) Editing
(B) Linking
(C) Maintaining
(D) Testing

5. ONE advantage of a high-level language over a low-level language is that it is
(A) harder to read
(B) machine-dependent
(C) easier to learn and portable
(D) always faster

Show answers

1. C
2. B
3. B
4. B
5. C

Paper 2 practice (structured question)

A programmer in Georgetown writes a program in C to keep track of a shop’s stock.

(a) Distinguish between a low-level language and a high-level language. (2 marks)

(b) Name TWO types of low-level language. (2 marks)

(c) Describe the following steps in implementing a program:

(i) compiling (1 mark)

(ii) linking (1 mark)

(iii) executing (1 mark)

(d) State ONE difference between a compiler and an interpreter. (2 marks)

(e) Explain why maintenance is a step in implementing a program. (1 mark)

Total: 10 marks

Show answers

(a) A low-level language is close to machine code and machine-dependent (1 mark); a high-level language uses English-like statements and must be translated / is portable (1 mark).

(b) Machine language (1 mark); assembly language (1 mark).

(c)

(i) Translating the whole source code into object/machine code and reporting syntax errors (1 mark)

(ii) Combining the object code with library routines to make an executable file (1 mark)

(iii) Running the executable program so the computer carries out the instructions (1 mark)

(d) A compiler translates the whole program before it is run (1 mark); an interpreter translates and runs it one line at a time (1 mark).

(e) Programs need to be corrected and updated over time as errors are found or requirements change (1 mark).

Next: Program Errors, Testing and Debugging: Syntax, Logic and Runtime Errors

Syllabus link: This post is relevant to the CSEC® Information Technology Syllabus (CXC 30/G/SYLL 17), Section 8: Program Implementation, Specific Objectives 1 and 2 (“distinguish between low-level and high-level programming languages” and “describe the sequence of steps in implementing a program”).

Attributions to media used in this post:

Updates

2026/10/16

– Syntax highlighting added to code examples.

© 2026 Vedesh Kungebeharry. All rights reserved.

Testing Algorithms with Trace Tables (Desk Checks and Dry Runs)

How do you know your algorithm works before you type it into a computer? You do a desk check (also called a dry run): you pretend to be the computer and follow each step with pencil and paper, using a trace table to record the values.

Build on what you learned in Forms 1–3

These Lower School ICT posts cover the basics of this topic:

In this post:

  • What is a desk check / dry run?
  • How to build a trace table
  • Worked example with a loop
  • Using a trace table to find an error
  • Choosing test data

Desk checks and trace tables

A trace table has a column for each variable (identifier) and, if needed, a column for the output. You fill in one row for each pass (each time the loop runs or a value changes). At the end, compare the output with what you expected – if they match, the algorithm is correct for that test data.

Steps to complete a trace table

  1. Draw a column for each variable, plus Output.
  2. Go through the algorithm one line at a time.
  3. Every time a variable is given a new value, write it in its column (on a new row for each pass of a loop).
  4. When something is printed, write it in the Output column.
  5. Keep going until the algorithm ends.

Worked example

Pseudocode

1  total ← 0
2  count ← 1
3  WHILE count <= 4 DO
4      total ← total + count * 2
5      count ← count + 1
6  ENDWHILE
7  PRINT total
PasscounttotalOutput
Start10
122
236
3412
4520
End (count <= 4 is FALSE)52020

Notice that total goes 0 → 2 → 6 → 12 → 20, because each time we add count × 2 (2, 4, 6, 8). When count becomes 5, the condition count <= 4 is FALSE, so the loop stops and 20 is printed.

Using a trace table to find an error

Kerry-Ann wants to find the average of 3 numbers but her algorithm says average ← num1 + num2 + num3 / 3. Trace it with 60, 70 and 80:

num1num2num3averageExpected
607080156.6770

The trace table shows the answer is wrong. Only num3 was divided by 3! The fix is average ← (num1 + num2 + num3) / 3. This is a logic error – more on that in Section 8.

Choosing test data

Test with normal data (typical values), boundary data (values right at the edge, e.g. a mark of exactly 50 when the pass mark is 50) and erroneous data (values that should be rejected, like a mark of −5).

Try it: Trace table filler

Complete the trace table for this algorithm. Each row shows the values at the end of that pass.

x ← 3
y ← 1
FOR i ← 1 TO 3 DO
    y ← y * x
    x ← x − 1
ENDFOR
PRINT y
iyx
(start)13
1
2
3

What is printed at the end? (Answer: 6.)

Related

Related class recordings:
• How to Approach a Dry run using test data and trace tables to uncover errors in your algorithm
• Trace Table Exercise – Form 5 Opt D – 2025-10-08_08-55-28
• Reinforcement of Control Structures, Trace table test – Live class 5 OptD (2026-10-07_09-56-46)

Paper 1 practice (multiple choice)

Choose the best answer for each question. Try them all before you check.

1. A trace table is used to
(A) translate a program
(B) test an algorithm by recording the values of variables
(C) draw a flowchart
(D) store a program

2. In a trace table, the column headings are usually
(A) the line numbers only
(B) the variable names (identifiers)
(C) the flowchart symbols
(D) the programmer’s name

3. Working through an algorithm by hand to check it is called a
(A) compile
(B) dry run
(C) syntax check
(D) link

4. Given x ← 5, then x ← x + 3, then x ← x * 2, the final value of x is
(A) 10
(B) 16
(C) 13
(D) 8

5. Testing a pass-mark program with a mark of exactly 50 uses
(A) erroneous data
(B) boundary (extreme) data
(C) random data
(D) no data

Show answers

1. B
2. B
3. B
4. B
5. B

Paper 2 practice (structured question)

Study the following algorithm:

sum ← 0
FOR n ← 1 TO 4 DO
    READ value
    sum ← sum + value
ENDFOR
average ← sum / 4
PRINT sum, average

(a) Explain what is meant by a “dry run”. (2 marks)

(b) Copy and complete a trace table for the algorithm using the data 6, 3, 9, 2. (4 marks)

(c) State the output of the algorithm for this data:

(i) the sum (1 mark)

(ii) the average (1 mark)

(d) Identify the type of loop used in the algorithm. (1 mark)

Total: 9 marks

Show answers

(a) Working through the algorithm by hand, step by step (1 mark), recording the values of variables to check that the results are correct (1 mark).

(b)
• n = 1, value = 6, sum = 6 (1 mark)
• n = 2, value = 3, sum = 9 (1 mark)
• n = 3, value = 9, sum = 18 (1 mark)
• n = 4, value = 2, sum = 20 and average = 5 (1 mark)

(c)

(i) 20 (1 mark)

(ii) 5 (1 mark)

(d) FOR loop / counter-controlled loop (1 mark).

Next: Low-Level vs High-Level Languages and the Steps in Implementing a Program

Syllabus link: This post is relevant to the CSEC® Information Technology Syllabus (CXC 30/G/SYLL 17), Section 7: Problem-Solving and Program Design, Specific Objective 7 (“test algorithms for correctness”).

Attributions to media used in this post:

No third-party images are used in this post. Embedded videos are credited on YouTube to their channels.

© 2026 Vedesh Kungebeharry. All rights reserved.

Operators in Algorithms: Arithmetic, Relational and Logical Operators, Truth Tables, MOD and DIV

Algorithms do calculations and make decisions using operators. In this post you will learn the arithmetic operators (including MOD and DIV), the relational operators used to compare values, and the logical operators AND, OR, NOT with their truth tables.

Build on what you learned in Forms 1–3

These Lower School ICT posts cover the basics of this topic:

In this post:

  • Arithmetic operators, MOD and DIV
  • Relational operators
  • Logical operators AND, OR, NOT
  • Truth tables
  • Using operators in pseudocode and code

Arithmetic operators

OperatorMeaningExampleResult
+Add7 + 310
−Subtract7 − 34
*Multiply7 * 321
/Divide7 / 23.5
DIVWhole-number (integer) division – how many times it goes in17 DIV 53
MODRemainder after whole-number division17 MOD 52

MOD and DIV are very useful. Example: a fete has 135 minutes of music. 135 DIV 60 = 2 hours and 135 MOD 60 = 15 minutes. Another common use: a number is even if number MOD 2 = 0.

Pseudocode

READ total_minutes
hours ← total_minutes DIV 60
minutes ← total_minutes MOD 60
PRINT total_minutes, " minutes = ", hours, " hours and ", minutes, " minutes"

Python

# Convert minutes into hours and minutes using DIV and MOD
total_minutes = int(input("Enter the number of minutes: "))
hours = total_minutes // 60      # DIV
minutes = total_minutes % 60     # MOD
print(total_minutes, "minutes =", hours, "hours and", minutes, "minutes")

C

/* Convert minutes into hours and minutes using DIV and MOD */
#include <stdio.h>

int main(void)
{
    int total_minutes, hours, minutes;

    printf("Enter the number of minutes: ");
    scanf("%d", &total_minutes);
    hours = total_minutes / 60;      /* DIV (integer division) */
    minutes = total_minutes % 60;    /* MOD (remainder) */
    printf("%d minutes = %d hours and %d minutes\n", total_minutes, hours, minutes);
    return 0;
}

Sample run with 135: 135 minutes = 2 hours and 15 minutes. In Python, DIV is // and MOD is %; in C, / between two integers does DIV and % is MOD.

Relational operators

Relational operators compare two values. The answer is always TRUE or FALSE.

CSEC pseudocodeMeaningPythonC
<less than<<
>greater than>>
=equal to====
<=less than or equal to<=<=
>=greater than or equal to>=>=
<>not equal to!=!=

Example: IF age >= 17 THEN PRINT "You may apply for a learner’s permit". You can practise these in Relational Operators – A practical Exercise.

Logical operators and truth tables

  • AND – TRUE only if both conditions are TRUE.
  • OR – TRUE if at least one condition is TRUE.
  • NOT – reverses the value: NOT TRUE = FALSE.

A truth table shows the result for every possible combination of inputs.

ABA AND BA OR B
TRUETRUETRUETRUE
TRUEFALSEFALSETRUE
FALSETRUEFALSETRUE
FALSEFALSEFALSEFALSE
ANOT A
TRUEFALSE
FALSETRUE

Everyday example: A child gets into the Carnival kiddies’ fete free IF they are under 12 AND with an adult. A 10-year-old alone → TRUE AND FALSE = FALSE, so no free entry. A scholarship is given IF average >= 80 OR the student won the science fair – only one needs to be TRUE.

Pseudocode

READ age, with_adult
IF age < 12 AND with_adult = TRUE THEN
    PRINT "Free entry"
ELSE
    PRINT "Pay at the gate"
ENDIF

In Python these are written and, or, not; in C they are &&, || and !.

Optional extension: how computers use AND, OR and NOT (Boolean logic) at the hardware level.

Video: Boolean Logic & Logic Gates: Crash Course Computer Science #3 – https://www.youtube.com/watch?v=gI-qXk7XojA

Try it: Complete the truth table

Type TRUE or FALSE in each box, then check.

ABA AND BA OR BNOT A
TRUETRUE
TRUEFALSE
FALSETRUE
FALSEFALSE

Try it: MOD and DIV practice

Work out each answer.

ExpressionAnswer
17 DIV 5
17 MOD 5
20 MOD 4
9 DIV 2
250 MOD 60

Related

Related: Relational Operators – A practical Exercise

Paper 1 practice (multiple choice)

Choose the best answer for each question. Try them all before you check.

1. What is the value of 23 MOD 4?
(A) 5
(B) 3
(C) 5.75
(D) 4

2. What is the value of 23 DIV 4?
(A) 5
(B) 3
(C) 5.75
(D) 6

3. Which relational operator means “not equal to” in CSEC pseudocode?
(A) =
(B) <>
(C) >=
(D) !

4. If A is TRUE and B is FALSE, what is A AND B?
(A) TRUE
(B) FALSE
(C) Both
(D) Cannot tell

5. If A is FALSE and B is TRUE, what is A OR B?
(A) TRUE
(B) FALSE
(C) NOT B
(D) Cannot tell

Show answers

1. B
2. A
3. B
4. B
5. A

Paper 2 practice (structured question)

A minibus company charges students half price IF they are in uniform AND travelling before 6:00 p.m. A program uses the Boolean variables in_uniform and before_six.

(a) State the result of EACH of the following:

(i) 29 MOD 7 (1 mark)

(ii) 29 DIV 7 (1 mark)

(b) Copy and complete a truth table for in_uniform AND before_six, showing all FOUR combinations. (4 marks)

(c) Explain the difference between the AND and OR logical operators. (2 marks)

(d) Write a pseudocode IF statement that prints “Half price” when a student qualifies, and “Full price” otherwise. (2 marks)

Total: 10 marks

Show answers

(a)

(i) 1 (1 mark)

(ii) 4 (1 mark)

(b)
• TRUE, TRUE → TRUE (1 mark)
• TRUE, FALSE → FALSE (1 mark)
• FALSE, TRUE → FALSE (1 mark)
• FALSE, FALSE → FALSE (1 mark)

(c) AND gives TRUE only when both conditions are TRUE (1 mark); OR gives TRUE when at least one of the conditions is TRUE (1 mark).

(d) IF in_uniform = TRUE AND before_six = TRUE THEN PRINT “Half price” (1 mark); ELSE PRINT “Full price” ENDIF (1 mark).

Next: Testing Algorithms with Trace Tables (Desk Checks and Dry Runs)

Syllabus link: This post is relevant to the CSEC® Information Technology Syllabus (CXC 30/G/SYLL 17), Section 7: Problem-Solving and Program Design, Specific Objective 6 (“represent algorithms in the form of flowchart and pseudocode”).

Attributions to media used in this post:

No third-party images are used in this post. Embedded videos are credited on YouTube to their channels.

Updates

2026/10/16

– Syntax highlighting added to code examples.

© 2026 Vedesh Kungebeharry. All rights reserved.

Flowcharts and Pseudocode: Sequence, Selection and Loops

Now that you know what an algorithm is, you need to be able to write one the way CSEC expects – as a flowchart or in pseudocode. This post covers the flowchart symbols, the pseudocode keywords, and the control structures: sequence, selection and loops (repetition).

Build on what you learned in Forms 1–3

These Lower School ICT posts cover the basics of this topic:

In this post:

  • Flowchart symbols
  • Pseudocode keywords
  • Sequence
  • Selection: IF-THEN, IF-THEN-ELSE and nested IF
  • Loops: FOR, WHILE and REPEAT-UNTIL

Video: Computer Science Basics: Sequences, Selections, and Loops – https://www.youtube.com/watch?v=eSYeHlwDCNA

Flowchart symbols

Start / StopTerminator – start or endInput / OutputInput/Output – read or displayProcessProcess – calculation or assignmentDecision?Decision – a yes/no questionFlow line – shows the direction
The flowchart symbols you need for CSEC.
A simple flowchart for fixing a lamp that does not work. The diamonds are decisions (yes/no questions) and the rectangles are actions.
A simple flowchart for fixing a lamp that does not work. The diamonds are decisions (yes/no questions) and the rectangles are actions.

Image source: File:LampFlowchart.svg

Pseudocode keywords

  • Input: READ or INPUT
  • Output: PRINT, WRITE, OUTPUT or DISPLAY
  • Storing a value (assignment): STORE, or an arrow such as total ← 0 (some teachers use =)
  • Decisions: IF … THEN … ELSE … ENDIF
  • Loops: FOR … ENDFOR, WHILE … ENDWHILE, REPEAT … UNTIL

Sequence

In a sequence, the steps are carried out one after another, in order. Example: find the average of three test scores.

Pseudocode

START
    READ score1, score2, score3
    average ← (score1 + score2 + score3) / 3
    PRINT "The average is ", average
STOP
StartInput score1, score2, score3average ← (s1 + s2 + s3) / 3Output averageStop
Flowchart for the average of three scores (sequence).

Selection

Selection lets the algorithm make a decision and choose which steps to carry out.

IF-THEN-ELSE

START
    READ mark
    IF mark >= 50 THEN
        PRINT "Pass"
    ELSE
        PRINT "Fail"
    ENDIF
STOP
StartInput markmark >= 50?YesNoOutput "Pass"Output "Fail"Stop
Flowchart for the Pass/Fail decision. A decision diamond has two exits: Yes and No.

A nested IF is an IF inside another IF. It is used when there are more than two choices, such as grades:

Nested IF

READ mark
IF mark >= 75 THEN
    PRINT "Grade A"
ELSE
    IF mark >= 60 THEN
        PRINT "Grade B"
    ELSE
        PRINT "Grade C"
    ENDIF
ENDIF

Loops (repetition)

A loop repeats a set of steps. CSEC uses three kinds:

  • FOR loop – repeats a known number of times (counter-controlled).
  • WHILE loop – checks a condition first, and repeats while it is true. It may run zero times.
  • REPEAT-UNTIL loop – does the steps first, then checks the condition at the end, so it always runs at least once.

FOR loop: add up 5 prices

total ← 0
FOR count ← 1 TO 5 DO
    READ price
    total ← total + price
ENDFOR
PRINT "Total: ", total
Starttotal ← 0, count ← 1count <= 5?YesInput pricetotal ← total + pricecount ← count + 1NoOutput totalStop
Flowchart for the FOR loop above. The arrow going back up shows the repetition.

WHILE loop: keep going until -1 is entered (a sentinel or rogue value)

READ mark
WHILE mark <> -1 DO
    IF mark >= 50 THEN
        PRINT "Pass"
    ELSE
        PRINT "Fail"
    ENDIF
    READ mark
ENDWHILE

REPEAT-UNTIL loop: ask for the PIN until it is correct

REPEAT
    READ pin
UNTIL pin = 1234
PRINT "Welcome"

Algorithm and program side by side

Here is a loop like the FOR example turned into real programs (the number of items is read first, and VAT is added as a constant). You will learn how to do this translation in Section 8.

Python

# Total a shopping bill and add VAT
VAT_RATE = 0.125          # constant: 12.5% VAT

num_items = int(input("How many items? "))
subtotal = 0.0
for i in range(num_items):
    price = float(input("Enter price: $"))
    subtotal = subtotal + price
vat = subtotal * VAT_RATE
total = subtotal + vat
print("Subtotal: $" + format(subtotal, ".2f"))
print("VAT: $" + format(vat, ".2f"))
print("Total: $" + format(total, ".2f"))

C

/* Total a shopping bill and add VAT */
#include <stdio.h>

#define VAT_RATE 0.125    /* constant: 12.5% VAT */

int main(void)
{
    int num_items, i;
    float price, subtotal = 0.0, vat, total;

    printf("How many items? ");
    scanf("%d", &num_items);
    for (i = 1; i <= num_items; i++)
    {
        printf("Enter price: $");
        scanf("%f", &price);
        subtotal = subtotal + price;
    }
    vat = subtotal * VAT_RATE;
    total = subtotal + vat;
    printf("Subtotal: $%.2f\n", subtotal);
    printf("VAT: $%.2f\n", vat);
    printf("Total: $%.2f\n", total);
    return 0;
}

Sample run: 3 items costing 25, 40.50 and 10 → Subtotal: $75.50, VAT: $9.44, Total: $84.94.

Try it: Flowchart symbol and control structure matcher

Choose the correct answer for each.

Shape used for “Input price”
Shape used for “total ← total + price”
Shape used for “Is mark >= 50?”
Shape used for “Start” and “Stop”
Loop that repeats a known number of times
Loop that always runs at least once
Loop that checks its condition before running

Related

Related:
• Ways of representing algorithms
• Closure on Sequence with flow charts
• Flowchart Practise – Finding the average of 3 numbers.
• Selection Statements: Practise Exercise(s)
• Using multiple selection statements (By Example)

Paper 1 practice (multiple choice)

Choose the best answer for each question. Try them all before you check.

1. Which flowchart symbol is used for a decision?
(A) Rectangle
(B) Parallelogram
(C) Diamond
(D) Oval

2. Which pseudocode keyword is used to accept data from the user?
(A) PRINT
(B) READ
(C) STORE
(D) ENDIF

3. Which loop is BEST when you know exactly how many times to repeat?
(A) WHILE
(B) REPEAT-UNTIL
(C) FOR
(D) IF-THEN

4. A REPEAT-UNTIL loop differs from a WHILE loop because it
(A) never ends
(B) checks the condition at the end, so it runs at least once
(C) cannot contain IF statements
(D) runs exactly 10 times

5. Carrying out instructions one after the other in order is called
(A) selection
(B) iteration
(C) sequence
(D) nesting

Show answers

1. C
2. B
3. C
4. B
5. C

Paper 2 practice (structured question)

A school canteen gives a 10% discount on any lunch order costing more than $50. Otherwise there is no discount.

(a) Name the flowchart symbol used for EACH of the following:

(i) reading the cost of the order (1 mark)

(ii) checking whether the cost is more than $50 (1 mark)

(b) Write pseudocode to read the cost of ONE order and print the amount to pay after any discount. (5 marks)

(c) State the type of loop you would use to process orders until a cost of 0 is entered, and give ONE reason. (2 marks)

(d) Distinguish between sequence and selection. (2 marks)

Total: 11 marks

Show answers

(a)

(i) Parallelogram / input-output symbol (1 mark)

(ii) Diamond / decision symbol (1 mark)

(b) One mark for each marked line:

READ cost                            (1 mark)
IF cost > 50 THEN                    (1 mark)
    amount ← cost − (cost × 0.10)    (1 mark)
ELSE
    amount ← cost
ENDIF                                (1 mark for ELSE … ENDIF)
PRINT amount                         (1 mark)

(c) WHILE (or REPEAT-UNTIL) loop (1 mark); the number of orders is not known in advance, so the loop must stop when the sentinel value 0 is entered (1 mark).

(d) Sequence: instructions are carried out one after another in order (1 mark). Selection: a condition is tested and a choice is made about which instructions to carry out (1 mark).

Next: Operators in Algorithms: Arithmetic, Relational and Logical Operators, Truth Tables, MOD and DIV

Syllabus link: This post is relevant to the CSEC® Information Technology Syllabus (CXC 30/G/SYLL 17), Section 7: Problem-Solving and Program Design, Specific Objective 6 (“represent algorithms in the form of flowchart and pseudocode”).

Attributions to media used in this post:

Updates

2026/10/16

– Syntax highlighting added to code examples.

© 2026 Vedesh Kungebeharry. All rights reserved.

What Is an Algorithm? Definition and Characteristics of a Good Algorithm

You follow algorithms every day – a recipe for coconut bake, the steps to top up your phone credit, or directions to a friend’s house. In this post we look at what an algorithm is and the characteristics every good algorithm must have.

Build on what you learned in Forms 1–3

These Lower School ICT posts cover the basics of this topic:

In this post:

  • Definition of an algorithm
  • Characteristics of a good algorithm
  • Good vs bad algorithm examples
  • Ways of representing an algorithm

Video: Computer Science Basics: Algorithms – https://www.youtube.com/watch?v=kM9ASKAni_s

What is an algorithm?

An algorithm is a finite sequence of clear, step-by-step instructions for solving a problem or completing a task. A computer program is an algorithm written in a programming language so that a computer can follow it.

Characteristics of a good algorithm

The CSEC syllabus expects you to know that an algorithm:

  • has a finite number of steps – it does not go on forever;
  • is precise – each step is exact (e.g. “add 2 cups of flour”, not “add some flour”);
  • is unambiguous – each step has only one meaning, so everyone following it does the same thing;
  • has a flow of control from one process to another – the steps happen in a clear order; and
  • terminates – it comes to an end and produces a result.

Good and bad examples

Not a good algorithm stepWhyBetter version
Add sugar to tasteNot precise – how much?Add 2 tablespoons of sugar
Keep stirringNever ends – not finiteStir for 3 minutes
Turn at the big treeAmbiguous – which tree? which way?Turn left at the mango tree opposite the church

Example: topping up phone credit

  1. Start
  2. Dial the top-up code
  3. Enter the 16-digit voucher number
  4. Press Send
  5. Read the confirmation message
  6. Stop

This algorithm is finite (6 steps), precise, unambiguous, flows from one step to the next and terminates.

Ways of representing algorithms

Algorithms can be written as narrative (plain sentences), pseudocode (structured English-like statements) or as a flowchart (a diagram). CSEC focuses on pseudocode and flowcharts – see the next post and the earlier post Ways of representing algorithms.

Optional extension: famous algorithms such as sorting and finding the shortest route – the idea behind map apps.

Video: Intro to Algorithms: Crash Course Computer Science #13 – https://www.youtube.com/watch?v=rL8X2mlNHPM

Try it: Which characteristic is missing?

Each instruction breaks one characteristic of a good algorithm. Choose which one.

“Repeat forever: wipe the table”
“Pour in a little milk”
“Go to the shop by the school” (there are two schools nearby)
Steps are jumbled with no clear order

Related

Related:
• WHAT IS AN ALGORITHM? – DEFINITION
• Algorithms
• The purpose of an algorithm

Paper 1 practice (multiple choice)

Choose the best answer for each question. Try them all before you check.

1. An algorithm is BEST defined as
(A) a computer program in machine code
(B) a finite set of step-by-step instructions to solve a problem
(C) a diagram of computer hardware
(D) a programming language

2. “Bake until it looks nice” is NOT a good algorithm step because it is not
(A) finite
(B) precise
(C) a flowchart
(D) a program

3. Which characteristic means an algorithm must eventually stop?
(A) Unambiguous
(B) Terminates
(C) Precise
(D) Flow of control

4. Which is NOT a way of representing an algorithm?
(A) Pseudocode
(B) Flowchart
(C) Narrative
(D) Compiler

5. Each instruction in an algorithm should have only one meaning. This is called being
(A) finite
(B) unambiguous
(C) efficient
(D) terminated

Show answers

1. B
2. B
3. B
4. D
5. B

Paper 2 practice (structured question)

Shania writes these instructions for her younger brother to make a cup of cocoa tea: “Boil some water. Put cocoa in the cup. Add the water. Stir for a while. Add sugar if you want.”

(a) Define the term “algorithm”. (2 marks)

(b) State THREE characteristics of a good algorithm. (3 marks)

(c) Identify TWO steps in Shania’s instructions that are not precise and rewrite EACH so that it is precise. (4 marks)

(d) Name ONE way, other than narrative, to represent an algorithm. (1 mark)

Total: 10 marks

Show answers

(a) A finite sequence of step-by-step instructions (1 mark) for solving a problem or completing a task (1 mark).

(b) Any three (1 mark each):
• finite number of steps
• precise
• unambiguous
• flow of control from one process to another
• terminates

(c) Any two steps identified (1 mark each) with a precise rewrite (1 mark each), e.g.
• “Boil some water” → “Boil 1 cup of water”
• “Stir for a while” → “Stir for 30 seconds”
• “Put cocoa in the cup” → “Put 2 teaspoons of cocoa in the cup”

(d) Pseudocode OR flowchart (1 mark).

Next: Flowcharts and Pseudocode: Sequence, Selection and Loops

Syllabus link: This post is relevant to the CSEC® Information Technology Syllabus (CXC 30/G/SYLL 17), Section 7: Problem-Solving and Program Design, Specific Objective 5 (“explain the concept of algorithms”).

Attributions to media used in this post:

No third-party images are used in this post. Embedded videos are credited on YouTube to their channels.

© 2026 Vedesh Kungebeharry. All rights reserved.

Variables, Constants and Data Types: Integer, Real, Character, String and Boolean

Every program stores data while it runs – a student’s name, a price, the number of goals scored. In this post you will learn the difference between a variable and a constant, and the five data types you need for CSEC: integer, real (floating point), character, string and Boolean.

Build on what you learned in Forms 1–3

These Lower School ICT posts cover the basics of this topic:

In this post:

  • What is a variable?
  • What is a constant?
  • Naming variables (identifiers)
  • Data types with examples

Variables

A variable is a named area of storage (in memory) whose value can change while the program is running. Think of it like a labelled box: the label is the name (for example score) and you can take out the old value and put in a new one at any time.

Example: in a cricket scoring program, runs starts at 0 and changes every time the batsman scores.

Constants

A constant is a named value that never changes while the program is running. Examples: the VAT rate (12.5% in Trinidad and Tobago), the number of days in a week (7), the pass mark (50), or π (3.14159).

Why use a constant instead of just typing the number? If the VAT rate changes, you only change it in one place, and a name like VAT_RATE is easier to understand than 0.125.

Naming variables (identifiers)

  • Use meaningful names: total_price is better than tp or x.
  • Start with a letter; no spaces (use an underscore instead, e.g. first_name).
  • Do not use words that the language already uses, such as if or while.
  • Many programmers write constants in CAPITALS, e.g. PASS_MARK.

Data types

The data type tells the computer what kind of value a variable will hold, and therefore what can be done with it.

Data typeWhat it storesExamples
IntegerWhole numbers (positive, negative or zero), no decimal point15 (age), −3, 0, 2026
Real (floating point)Numbers with a decimal (fractional) part12.50 (price), 1.62 (height), −0.5
CharacterA single letter, digit or symbol‘A’ (grade), ‘M’, ‘$’
StringA group (sequence) of characters, such as words or text“Kezia Ramdial”, “Port of Spain”, “868-555-1234”
BooleanOnly one of two values: TRUE or FALSEis_prefect = TRUE, has_paid = FALSE

Note: a telephone number such as 868-555-1234 is stored as a string, because you never do arithmetic with it and it contains dashes.

Shows how programs store values in variables and assign new values to them.

Video: Programming Basics: Statements & Functions: Crash Course Computer Science #12 – https://www.youtube.com/watch?v=l26oaHV7D40

A quick look in code

Here is how the five data types and a constant look in Python and C. (You will learn more about declaring variables in Section 8.)

Python

# Declaring (creating) variables and a constant in Python
SCHOOL_NAME = "Island Secondary"   # constant (by convention, CAPITALS)
age = 15                            # integer
height = 1.62                       # real (float)
grade = 'A'                         # character (a string of length 1)
name = "Kezia"                      # string
is_prefect = True                   # Boolean
print(name, "is", age, "years old and got grade", grade)
print("Height:", height, "m  Prefect:", is_prefect, " School:", SCHOOL_NAME)

C

/* Declaring variables and a constant in C */
#include <stdio.h>
#include <stdbool.h>

#define SCHOOL_NAME "Island Secondary"   /* constant */

int main(void)
{
    int age = 15;              /* integer */
    float height = 1.62;       /* real */
    char grade = 'A';          /* character */
    char name[20] = "Kezia";   /* string (array of characters) */
    bool is_prefect = true;    /* Boolean (1 = true, 0 = false) */

    printf("%s is %d years old and got grade %c\n", name, age, grade);
    printf("Height: %.2f m  Prefect: %d  School: %s\n", height, is_prefect, SCHOOL_NAME);
    return 0;
}

Sample output (Python): Kezia is 15 years old and got grade A / Height: 1.62 m Prefect: True School: Island Secondary. In C, the Boolean prints as 1 for true.

Try it: Choose the best data type

Choose the most suitable data type for each item.

The number of students in a class
The price of a bake and shark
A student’s grade, e.g. B
A customer’s name
Whether a fee has been paid (yes/no)
A WhatsApp phone number such as 1-876-555-0100
The temperature in °C, e.g. 31.5

Related

Related: Demo: Constants, Variables and Datatypes.

Paper 1 practice (multiple choice)

Choose the best answer for each question. Try them all before you check.

1. A storage location whose value can change while a program runs is called a
(A) constant
(B) variable
(C) data type
(D) compiler

2. Which data type is BEST for storing the price $45.99?
(A) Integer
(B) Character
(C) Real
(D) Boolean

3. Which value is a Boolean?
(A) “Yes please”
(B) TRUE
(C) 25
(D) ‘Y’

4. Which is the BEST example of a constant?
(A) A student’s age
(B) The number of days in a week
(C) The balance in a bank account
(D) The time of day

5. “Montego Bay” would be stored as a
(A) character
(B) integer
(C) string
(D) real

Show answers

1. B
2. C
3. B
4. B
5. C

Paper 2 practice (structured question)

A program is being written for a car rental company in Bridgetown. It stores the customer’s name, the number of days the car is rented, the daily rate of $95.50, whether the customer has insurance, and the car category (A, B or C).

(a) Distinguish between a variable and a constant. (2 marks)

(b) Identify the most suitable data type for EACH of the following:

(i) the customer’s name (1 mark)

(ii) the number of days rented (1 mark)

(iii) whether the customer has insurance (1 mark)

(iv) the car category (1 mark)

(c) The daily rate is the same for every customer. State whether it should be stored as a variable or a constant, and give ONE reason. (2 marks)

Total: 8 marks

Show answers

(a) A variable is a named storage location whose value can change during processing (1 mark); a constant’s value never changes during processing (1 mark).

(b)

(i) String (1 mark)

(ii) Integer (1 mark)

(iii) Boolean (1 mark)

(iv) Character (1 mark)

(c) Constant (1 mark); its value does not change while the program runs / it only needs to be changed in one place if the rate changes (1 mark).

Next: What Is an Algorithm? Definition and Characteristics of a Good Algorithm

Syllabus link: This post is relevant to the CSEC® Information Technology Syllabus (CXC 30/G/SYLL 17), Section 7: Problem-Solving and Program Design, Specific Objective 4 (“distinguish between variables and constants”).

Attributions to media used in this post:

No third-party images are used in this post. Embedded videos are credited on YouTube to their channels.

Updates

2026/10/16

– Syntax highlighting added to code examples.

© 2026 Vedesh Kungebeharry. All rights reserved.

Defining a Problem with an IPO Chart: Input, Processing and Output

Before you write an algorithm, you must be clear about what goes in, what must happen, and what must come out. CSEC calls this defining a problem by decomposing it into its significant components. The tool we use is the IPO chart (also called a defining diagram).

Build on what you learned in Forms 1–3

These Lower School ICT posts cover the basics of this topic:

In this post:

  • Input, processing and output
  • How to build an IPO chart
  • Worked examples
  • Turning an IPO chart into an algorithm

The three components

  • Input – the data that must be given to the solution (what the user types in or what is read). Look for nouns in the problem such as “the price”, “three marks”, “the number of hours”.
  • Processing – the steps or calculations that change the input into the output. Look for verbs such as “calculate”, “add”, “find”, “compare”.
  • Output – the results the solution must produce or display. Look for words like “print”, “display”, “output”.

An IPO chart is simply a table with three columns: Input, Processing and Output.

Worked example 1: area of a garden plot

Problem: Write an algorithm to read the length and width of a rectangular garden plot and print its area.

InputProcessingOutput
length, widthRead length and width
Calculate area = length × width
Display area
area

Worked example 2: electricity bill

Problem: A customer is charged $0.45 for every kilowatt-hour (kWh) used plus a fixed charge of $20. Read the number of kWh used and print the amount due.

InputProcessingOutput
units used (kWh)Read units
Calculate amount = (units × 0.45) + 20
Display amount
amount due

Notice that the rate ($0.45) and the fixed charge ($20) are not inputs – they are given in the question and never change, so they are constants. You will learn more about this in the next post.

Worked example 3: highest of three cricket scores

Problem: Read the scores of three batsmen and print the highest score.

InputProcessingOutput
score1, score2, score3Read the three scores
Compare the scores to find the highest
Display the highest
highest score

From IPO chart to algorithm

Once the IPO chart is done, the algorithm almost writes itself. For the garden plot:

Pseudocode

START
    READ length, width
    area ← length * width
    PRINT "The area is ", area
STOP

Tip for exams: in the Processing column, write the steps in the order they happen and include the formula. Do not put the output values in the Input column!

Try it: Input, Processing or Output?

A program must read a student’s three test marks, calculate the average and display the average and a “Pass” or “Fail” message. Classify each item.

The three test marks
Add the three marks and divide by 3
The average mark
Check whether the average is 50 or more
The message “Pass” or “Fail”

Paper 1 practice (multiple choice)

Choose the best answer for each question. Try them all before you check.

1. In an IPO chart, the “P” stands for
(A) printing
(B) processing
(C) program
(D) pseudocode

2. A program reads the price of an item and the quantity bought, then displays the total cost. The INPUTS are
(A) total cost only
(B) price and quantity
(C) price, quantity and total cost
(D) quantity only

3. Which of the following belongs in the Processing column?
(A) The number of hours worked
(B) Calculate pay = hours × rate
(C) The pay
(D) A printed payslip

4. An IPO chart is used to
(A) translate a program into machine code
(B) define a problem by breaking it into its components
(C) find syntax errors
(D) store data in memory

5. A program calculates the area of a circle using πr². Which is an input?
(A) π
(B) the radius
(C) the area
(D) the formula

Show answers

1. B
2. B
3. B
4. B
5. B

Paper 2 practice (structured question)

A taxi driver in Kingston charges a fixed fee of $300 plus $150 for every kilometre travelled. A program is needed to read the distance travelled and display the fare.

(a) State the meaning of EACH of the following terms in problem-solving:

(i) input (1 mark)

(ii) output (1 mark)

(b) Draw an IPO chart for the taxi fare problem. (4 marks)

(c) Identify ONE constant in this problem. (1 mark)

(d) Write the formula used in the processing step. (1 mark)

Total: 8 marks

Show answers

(a)

(i) The data that must be supplied to the solution for it to be solved (1 mark)

(ii) The result(s) that the solution must produce or display (1 mark)

(b) Input: distance (1 mark). Processing: read distance (1 mark); calculate fare = 300 + 150 × distance (1 mark). Output: fare (1 mark).

(c) The fixed fee of $300 OR the rate of $150 per kilometre (1 mark).

(d) Fare = 300 + (150 × distance) (1 mark).

Next: Variables, Constants and Data Types: Integer, Real, Character, String and Boolean

Syllabus link: This post is relevant to the CSEC® Information Technology Syllabus (CXC 30/G/SYLL 17), Section 7: Problem-Solving and Program Design, Specific Objective 3 (“define a problem by decomposing it into its significant components”).

Attributions to media used in this post:

No third-party images are used in this post. Embedded videos are credited on YouTube to their channels.

© 2026 Vedesh Kungebeharry. All rights reserved.