← IGCSE Computer Science Paper 2

Comments with // (8.1a)

Starts a comment. Everything after // on that line explains the code to people and is ignored when the program runs, so it never changes what the program does.

Understanding Comments with // (8.1a) in IGCSE Computer Science Paper 2

What it does: Cambridge pseudocode has no block comment, so each line of a longer comment must begin with //. The comment after // is ignored, so X is still assigned 10 and OUTPUT X displays 10. Comments are written for people to read. The computer ignores everything after // on that line. Comments explain the code but are not run, so adding or removing them never changes the program's behaviour. An end-of-line comment needs // after the code. Without //, the words 'cost of 3 items' would be treated as code and cause an error. The broken line uses / (division) instead of // so the explanation is not a comment. It should be: Score ← 0 // set score to zero.

Common mistakes: Cambridge pseudocode comments start with //, not #. The line should be Score ← 0 // start at zero. A comment needs two forward slashes. A single / is not a comment, so the words would be read as code. It should be // Ask for the user's name.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 347–357) and word search (Modules 337–357).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which line is a correct comment in Cambridge pseudocode?
Store the player's score //// Store the player's score
Matches
Score ← 0 / set score to zero
↓
A single slash does not start a comment. It must be two slashes //, otherwise the text is treated as code and causes an error.
Applying
Meanings
Term
//
Meaning
Starts a comment. Everything after // on that line explains the code to people and is ignored when the program runs, so it never changes what the program does.
Practice
// Calculate the area of a rectangle
Testing
Gaps
Set the starting score
Check Answer
Spots
2DECLARE Score : INTEGER
3Score ← 0 # start at zero

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Snow Leopard' badge — Silent Debugger, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which line is a correct comment in Cambridge pseudocode?
A. Store the player's score //
B. // Store the player's score ✓
A comment starts with //. Everything after the // on that line is the comment, so the // must come before the explanation text.
2. What happens to the text after // when the program runs?
A. It is run as code
B. It is ignored ✓
Comments are written for people to read. The computer ignores everything after // on that line.
3. Which program prints the same output as the other three when the comment is removed? Pick the statement that is true about comments.
A. Adding a comment does not change what the program does ✓
B. Adding a comment changes the value stored in the variable
Comments explain the code but are not run, so adding or removing them never changes the program's behaviour.
4. Which line puts a short comment at the end of a line of code?
A. Total ← Price * 3 // cost of 3 items ✓
B. Total ← Price * 3 cost of 3 items
An end-of-line comment needs // after the code. Without //, the words 'cost of 3 items' would be treated as code and cause an error.
5. A comment needs to explain code that runs over two lines. Which is correct?
A. // Calculate the total cost // including the delivery fee ✓
B. // Calculate the total cost including the delivery fee
Each line of a multi-line comment must start with its own //. The second line without // would be treated as code.

Match the Pairs

// Calculate the area → A comment on its own line that explains the code below it and is ignored when the program runs
Total ← Price * Qty // cost of items → A statement followed by an end-of-line comment: the assignment runs but the comment is ignored
A comment that spans several lines needs // at the start of every line → // Program to find the average // Input three marks and output the mean
Adding a comment does not change what the program does, so the program still outputs 10 → X ← 10 // set X to ten OUTPUT X
Score ← 0 / set score to zero → A single slash does not start a comment. It must be two slashes //, otherwise the text is treated as code and causes an error.
// Ask the user for a name and store it in Name INPUT Name → The second line of the comment is missing //, so it would be treated as code and cause an error.

Key Term

//
Starts a comment. Everything after // on that line explains the code to people and is ignored when the program runs, so it never changes what the program does.

Fill in the Blanks

1. // Set the starting score Score ← 0
Hint: Type the two-slash symbol that starts a comment on its own line before the code.
2. Total ← Price * Quantity // cost of items
Hint: Type the symbol that begins a short comment at the end of a line.
3. // Calculate the area of a rectangle // Width and Height are in cm Area ← Width * Height
Hint: A comment that continues onto a second line must start with the comment symbol again.
4. OUTPUT Total // show the final total
Hint: Type the keyword that displays a value. The comment after it is ignored when the program runs.
5. Lives ← 3 // player starts with 3 lives
Hint: Type the assignment operator that stores the value in the variable. The comment only explains the line.

Spot the Error

Question 1
A // Store the player's score
B DECLARE Score : INTEGER
C Score ← 0 # start at zero
D OUTPUT Score
Line C — Cambridge pseudocode comments start with //, not #. The line should be Score ← 0 // start at zero.
Question 2
A / Ask for the user's name
B DECLARE Name : STRING
C INPUT Name
D OUTPUT "Hello ", Name
Line A — A comment needs two forward slashes. A single / is not a comment, so the words would be read as code. It should be // Ask for the user's name.
Question 3
A CONSTANT Pi ← 3.142
B INPUT Radius
C // Work out the circle area
D // Area ← Pi * Radius ^ 2
E OUTPUT Area
Line D — The // turned the calculation into a comment, so it never runs and Area has no value. The calculation should be Area ← Pi * Radius ^ 2 with no // before it. The comment belongs on its own line above.
Question 4
A DECLARE Lives : INTEGER
B Lives ← // starting lives 3
C OUTPUT Lives
Line B — Everything after // is ignored, so the 3 is now part of the comment and the assignment has no value. The comment must go after the code: Lives ← 3 // starting lives.
Question 5
A // Program: temperature check
B // Written for Year 10
C Converts C to F
D INPUT Celsius
E OUTPUT Celsius * 9 / 5 + 32
Line C — In a multi-line comment, every line must start with //. Without it, this line is treated as code. It should be // Converts C to F.

Student with a class code? Join your class →