C++ Comments

Comments in c++ are the non-executable line of code.  It is used by the programmer to make the code more readable for himself or for other programmers. It is written for the convenience of the programmer to make the code easier to understand.

There are two types of comments

  1. Single Line Comment
  2. Multi-Line Comment

Single Line Comment

 A line that starts with a “//” symbol is called a single-line comment. Below is an example of a single-line comment in c++

//comments in C++
#include<iostream>
using namespace std;
int main()
{

cout << "Hellow World" ;

}

Output

Hellow World

Multi-Line comment

A multiline comment begins with the “/*” and ends with “*/”. They are used to comment multiple lines in c++.  Any text between them is ignored by the compiler during program execution. Below is an example of a multi-line comment.

#include<iostream>
using namespace std;
int main()
{
/* this is the statement to print
Hello World on the computer screen */
cout << "Hellow World" ;
	
}

Output

Hellow World