C++ Comments

Study what comments are and why we should write them.

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. The source code of a website consists of thousands of lines. To repair the code, you have to understand it first. It’s quite an impractical approach to read every line of the code. Here, comments come to the rescue!

Get hands-on with 1200+ tech skills courses.