Skip to content

Comments

Comments help explain your code and are ignored during execution. Common Pseudocode supports both single-line and multi-line comments.

Single-line comments start with // and continue to the end of the line:

// This is a single-line comment
x = 5 // This is an inline comment

Multi-line comments are enclosed between /* and */:

/*
This is a multi-line comment
that spans multiple lines
*/
x = 10

You can also use multi-line comments inline:

result = /* intermediate calculation */ x * y
  • Use comments to explain why you’re doing something, not what you’re doing
  • Keep comments up-to-date with your code
  • Use single-line comments for brief explanations
  • Use multi-line comments for longer descriptions or temporarily disabling code blocks
// Good: Explains the reasoning
// Use binary search because the array is already sorted
index = binarySearch(sortedArray, target)
// Less helpful: Restates what the code does
// Call binarySearch function
index = binarySearch(sortedArray, target)