← IGCSE Computer Science Paper 2

Comments with // (7a)

Two forward slashes start a comment. Everything after // to the end of the line is ignored by the computer and only explains the code to the reader.

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

What it does: The // line is a comment placed above the INPUT statement to explain what it does. Pseudocode has no block comment, so each line of a longer comment begins with its own //. Everything after // is only an explanation for the reader. The computer ignores it. The // goes before the comment text. Code comes first, then // and the comment. Comments do not change what the program does. They help people understand the code. Two forward slashes // start a comment. Backslashes do not.

Common mistakes: Cambridge pseudocode comments start with //, not #. The line should be: Area ← Width * Width // square. A comment needs two forward slashes. A single / is the division operator, so the line should end with // add them.

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 17–26) and word search (Modules 1–26).

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 Cambridge pseudocode comment?
Add the two marks together //// Add the two marks together
Matches
/ Total of all the marks Total ← 0
↓
The comment starts with only one slash. A comment needs two forward slashes //, so the first line is not a valid comment.
Applying
Meanings
Term
//
Meaning
Two forward slashes start a comment. Everything after // to the end of the line is ignored by the computer and only explains the code to the reader.
Practice
// Ask for the test mark
Testing
Gaps
Ask the user for their age
Check Answer
Spots
3INPUT Width
4Area ← Width * Width # square

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

The 'Clownfish' badge — Reef Rookie, 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 Cambridge pseudocode comment?
A. // Add the two marks together ✓
B. Add the two marks together //
A comment starts with // and runs from there to the end of the line, so // must come first.
2. What does the computer do with the text after // on a line?
A. It ignores it ✓
B. It runs it as code
Everything after // is only an explanation for the reader. The computer ignores it.
3. Which is the correct way to put a short comment at the end of a line?
A. Total ← Total + Mark add mark //
B. Total ← Total + Mark // add mark ✓
The // goes before the comment text. Code comes first, then // and the comment.
4. A comment is placed on its own line above this code. Which is correct?
A. // Ask for the user's age INPUT Age ✓
B. Ask for the user's age INPUT Age
Without // the first line is not a comment, so it would be treated as code and cause an error.
5. A comment needs two lines. Which is correct?
A. // Check the password before logging in
B. // Check the password // before logging in ✓
A comment ends at the end of the line. Each line of a multi-line comment must start with //.

Match the Pairs

// Calculate the average mark → A comment on its own line above the code, explaining what the next lines do
Total ← Total + Mark // add to total → A short comment at the end of a line, explaining only that line of code
A comment that explains the purpose of the code is written on its own line above it → // Ask the user for their age INPUT Age
A multi-line comment needs // at the start of every line → // Check if the password is long enough // Passwords must have 8 or more characters
/ Total of all the marks Total ← 0 → The comment starts with only one slash. A comment needs two forward slashes //, so the first line is not a valid comment.
// Read the number // of students INPUT Students OUTPUT Students → Only the first two lines are comments, but a long comment that runs over several lines needs // on every line. A comment line without // would be treated as code.

Key Term

//
Two forward slashes start a comment. Everything after // to the end of the line is ignored by the computer and only explains the code to the reader.

Fill in the Blanks

1. // Ask the user for their age INPUT Age
Hint: Type the two-slash symbol that turns this whole line into a comment.
2. Total ← 0 // Start the total at zero
Hint: Type the symbol that starts a short comment at the end of a line of code.
3. // Calculate the area of the rectangle // Width and Length must be positive Area ← Width * Length
Hint: Each line of a multi-line comment must begin with the comment symbol. Type it for the second line.
4. FOR Count ← 1 TO 5 // Repeat five times OUTPUT Count NEXT Count
Hint: Type the symbol that begins the explanation after the code on the FOR line.
5. // Check if the student has passed IF Mark >= 50 THEN OUTPUT "Pass"
Hint: Type the symbol that makes the first line a comment on its own line above the code.

Spot the Error

Question 1
A DECLARE Width : INTEGER
B DECLARE Area : INTEGER
C INPUT Width
D Area ← Width * Width # square
E OUTPUT Area
Line D — Cambridge pseudocode comments start with //, not #. The line should be: Area ← Width * Width // square
Question 2
A // Total of two marks
B Total ← Mark1 + Mark2 / add them
C OUTPUT Total
Line B — A comment needs two forward slashes. A single / is the division operator, so the line should end with // add them.
Question 3
A // This program checks age
B and prints a message
C INPUT Age
D IF Age >= 18 THEN
E OUTPUT "Adult"
F ENDIF
Line B — Each line of a multi-line comment must start with //. Line 2 should be: // and prints a message
Question 4
A -- Ask for the user's name
B INPUT Name
C OUTPUT "Hello ", Name
Line A — -- is not the comment marker in Cambridge pseudocode. A comment above the code must start with //: // Ask for the user's name
Question 5
A DECLARE Count : INTEGER
B Count ← 0
C // add one Count ← Count + 1
D OUTPUT Count
Line C — Everything after // is ignored, so the code here would be ignored too. The code must come first and the comment after it: Count ← Count + 1 // add one

Student with a class code? Join your class →