C++ Comments


Comments in C++ program which provides clarity to the code is to allow others to understand what the code was identified to complete and help to fix the issue of the code.

There are 2 types of comments in C++.

  • Single Line Comments
  • Multi-Line Comments
C++ comments

Single Line Comments

Single line comments are defined by double slash(//).


Example:-

#include <iostream>   
using namespace std;
  
int main(){  
	//Simple Program - Single Line Comments
	cout << "Hello World"; 
   	return 0;
} 

Multi-Line Comments

Comments are defined in between /* and */ and will be ignored by the compiler.


Example:-

#include <iostream>   
using namespace std;
  
int main() {   
	 /*  simple hello word program 
     Multi-Line Comment*/  
	cout << "Hello World"; 
   	return 0;       
}

notepad
Comments are used to provide the piece of information about C++ program code.



OnlineTpoint is a website that is meant to offer basic knowledge, practice and learning materials. Though all the examples have been tested and verified, we cannot ensure the correctness or completeness of all the information on our website. All contents published on this website are subject to copyright and are owned by OnlineTpoint. By using this website, you agree that you have read and understood our Terms of Use, Cookie Policy and Privacy Policy.