Comments in C++ Programming Language


Program comments are explanatory statements that you can include in the C++ code. These comments help anyone reading the source code. All programming languages allow for some form of comments.

C++ supports single-line and multi-line comments. All characters available inside any comment are ignored by C++ compiler.

Single line comments

To create a single line comment, we use the // notation. Wherever you want to start the comment, start it with //. For example,

// This is a comment
cout<<"Hello"; // This is a comment following a statement.

Multiline comments

Multiline comments span multiple lines and are often called block comments. You can use it using the /* */ notation. For example,

/* This is
a Multiline
comment */

Updated on: 30-Jul-2019

165 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements