Search⌘ K

C++ Comments

Explore how to add single-line and multi-line comments in C++ source code to document and clarify your programs without affecting execution. Learn the importance of white spaces for enhancing code readability and maintenance. This lesson helps you write cleaner, well-organized C++ programs.

Introduction to comments

Comments are statements written inside the source code to make it easily understandable. The compiler ignores the comments, which is why they don’t affect the logic of our program.

📝Note: We write comments for the documentation of our program and to help other people understand our code.

Example

Suppose Educative hires you for the maintenance of its website. ...