C++ Comments

What is Comments?

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.

Single Line Comments

Single comment start with // in source code.

Example:

//single line comment example program
#include <iostream>
using namespace std; //incluse namespace std
int main() // main function
{
//output string
cout<<"Single line comment Example";
  return 0;
}

Multi Line Comments

Multi comment start with /* and end with */ in source code

Example:

/* Multi line comment example program
other line
other line */
#include <iostream>
using namespace std;
int main()
{
cout<<"Multi line comment Example";
  return 0;
}