Use of comments in C++

Program comments are explanatory statements that you can include in C++ code that you write and helps anyone reading its source code. All programming languages allows for some form of comments.

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

C++ comments start with /* and end with */. For example:

Use of comments in C++
Program comments are explanatory statements that you can include in C++ code that you write and helps anyone reading its source code. All programming languages allows for some form of comments.

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

C++ comments start with /* and end with */. For example:

/*This is a comment/*

/*C++ can also 
*use 
*multiple
*lines.
/*

A comment can also starts with // and it will be typed at the end of the line.

For example:

#include <iostream>
using namespace std;

int main(){

cout<<"Hello World"; //This is a comment

return 0;

}

When the above code is compiled, it will ignore // This is a comment and final executable will produce the following result:

Hello World Execution

CC BY 4.0 Use of comments in C++ by esaupreciado is licensed under a Creative Commons Attribution 4.0 International License.