← IGCSE Computer Science Paper 2

Comments with // (7c)

Starts a comment that runs to the end of the line. It explains the code to the reader but is not part of the algorithm, so it is ignored when run.

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

What it does: Pseudocode has no multi-line comment symbol, so every line of the comment starts with its own //. The // line explains the purpose of the IF statement but is not an instruction. The IF line is the algorithm. A comment is not part of the algorithm. It helps people read the code, so it is ignored when run. A comment can sit on its own line above the code it explains. It can also go at the end of a line. A comment runs only to the end of the line. Each extra line of comment needs its own //.

Common mistakes: Pseudocode comments start with //, not #. The line should be Total ← Price * 2 // doubled. A comment needs two slashes. A single / is not a comment. The line should be // Check for an adult.

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 136–145) and word search (Modules 123–145).

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 pseudocode comment?
// Add the marks togetherAdd the marks together //
Matches
Count ← Count + 1 Add one to the count
↓
The explanation has no // at the start, so it is not marked as a comment and looks like part of the code. It should be: Count ← Count + 1 // Add one to the count
Applying
Meanings
Term
//
Meaning
Starts a comment that runs to the end of the line. It explains the code to the reader but is not part of the algorithm, so it is ignored when run.
Practice
// Calculate the average of two marks
Testing
Gaps
Ask the user for their age
Check Answer
Spots
2DECLARE Total : REAL
3Total ← Price * 2 # doubled

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

The 'Pufferfish' badge — Error Handler, 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 pseudocode comment?
A. // Add the marks together ✓
B. Add the marks together //
A comment starts with // and runs to the end of the line, so the // must come before the comment text.
2. What does a comment do when the algorithm is run?
A. Nothing - it only explains the code to the reader ✓
B. It changes the value of a variable
A comment is not part of the algorithm. It helps people read the code, so it is ignored when run.
3. Where can a comment go?
A. On its own line above the code it explains ✓
B. Only at the very end of the program
A comment can sit on its own line above the code it explains. It can also go at the end of a line.
4. Which line has a short comment at the end of a line correctly?
A. Total ← Total + Mark Add mark to total //
B. Total ← Total + Mark // Add mark to total ✓
Write the code first, then // and the comment. Everything after // to the end of the line is the comment.
5. A comment needs 3 lines of explanation. How should it be written?
A. Put // on the first line only
B. Start every line with // ✓
A comment runs only to the end of the line. Each extra line of comment needs its own //.

Match the Pairs

// Add the mark to the total → A comment on its own line above the code, explaining what the next statement does
Total ← Total + Mark // running total → A short comment at the end of a line, explaining that statement without changing it
A comment that needs several lines must start each line with // → // Calculate the average // of the three test marks
A comment starts with // and explains the code without being part of the algorithm → // Check if the student passed IF Mark >= 50 THEN
Count ← Count + 1 Add one to the count → The explanation has no // at the start, so it is not marked as a comment and looks like part of the code. It should be: Count ← Count + 1 // Add one to the count
// Read the mark // and add it to Total Input Mark Total ← Total + Mark OUTPUT Total // → The comment on the second line is fine, but the last line ends with an empty //, which explains nothing. Also the comment lines should describe each statement. Remove the empty // or write a useful comment such as // Show the total

Key Term

//
Starts a comment that runs to the end of the line. It explains the code to the reader but is not part of the algorithm, so it is ignored when run.

Fill in the Blanks

1. // Ask the user for their age INPUT Age
Hint: Type the symbol that starts a comment on its own line above the code.
2. Total ← 0 // Start the total at zero
Hint: Type the symbol that begins a short comment at the end of a line of code.
3. // Add the three marks together // then divide by three to find the mean Average ← Total / 3
Hint: Each extra line of a multi-line comment needs its own comment symbol at the start.
4. // Repeat for each of the five students FOR Count ← 1 TO 5 INPUT Mark NEXT Count
Hint: Type the comment symbol that makes this explanation line ignored by the algorithm.
5. OUTPUT Total // Show the final total
Hint: Type the symbol that separates the code from the comment explaining it on the same line.

Spot the Error

Question 1
A // Double the price
B DECLARE Total : REAL
C Total ← Price * 2 # doubled
D OUTPUT Total
Line C — Pseudocode comments start with //, not #. The line should be Total ← Price * 2 // doubled.
Question 2
A INPUT Age
B / Check for an adult
C IF Age >= 18 THEN
D OUTPUT "Adult"
E ENDIF
Line B — A comment needs two slashes. A single / is not a comment. The line should be // Check for an adult.
Question 3
A DECLARE Total : INTEGER
B Total ← Mark1 + Mark2 + Mark3
C // Divide total by 3 to find
D the average mark
E Average ← Total / 3
Line D — A comment that runs over several lines needs // at the start of every line. The second line is missing its //, so it should be // the average mark.
Question 4
A Total ← 0
B FOR Count ← 1 TO 5
C // INPUT Num // read it
D Total ← Total + Num
E NEXT Count
Line C — The // at the start of the line turns the whole statement into a comment, so the number is never input. The line should be INPUT Num // read it.
Question 5
A /* Area of a rectangle */
B INPUT Length
C INPUT Width
D OUTPUT Length * Width
Line A — /* ... */ is not the pseudocode comment style. A comment starts with //, so the line should be // Area of a rectangle.

Student with a class code? Join your class →