C++ Comments

A C++ comment is a piece of descriptive text which explains some aspect of a program. The compiler totally ignores the program comment and are only intended for programmers or readers. There are two ways of writing comments.

  • // line comment
  • /* block comment */

The first one that is, the line comment, ignores everything from where the pair of slash sign(//) starts to the end of the line. The second one, the block comment, ignores everything between the start of the /* and to the end of the */. The second block comment may consist of a single line of comment or block of comment.

Syntax:

Example:

A C++ program that shows the use of comment using // line comment:

The output of the above program is:

Hello World

A C++ program that shows the use of comment using /* block comment */:

The output of the above program is:

Second Program
SHARE C++ Comments

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Share