Comments in C++

Comments in C++: Like all other programming languages we can also represent in C++. Comments are nothing but the explanatory statements that you can include in the code.

  • Single Line Comments: //
  • Multiple Line Comments: starts with /* and end with */

Comments in C++

This language supports both single-line and multiple-line comments. If they are present inside are ignored by C++ compiler. Here we can use  /* and end with */.

/*This is a comment */

/*C++ comments can also
   *span multiple lines
*/

From the above example, we can see that /*…*/ and  /* gives the same meaning.

And in C++ we can also start the comment with //.



Example:

#include <iostream>
using namespace std;
main() {
 cout<<"Hello Freshersnow";//prints freshersnow 
 return 0;
}

From the above example, we can see that comments within // also represents a comment.