Comment in C++

Comment in C++

Comments can be used to explain C++ code and Comments are portions of the code ignored by the compiler which allow the user to make simple notes in the relevant areas of the source code.

Comment in C++


{tocify} $title={Table of Contents}

We can use comment in many type in a program for ex:- we can explain the program by single line comment , we can declare the function() work in a program and etc.

Types of comment:-

In a C++/C comments are two types:-

1.    Single line comment

2.    Multiple line comment

Single line comment:-

 Singe line comment start with // and continue until the end of the line. If the last character in a comment line is a \ the comment will continue in the next line.

#include <iostream.h>

#include <conio.h>

 

Void main() {

 

Cout<<”this is a simple program”;   

// comment here 

 

}

 

 Multiple line comment:-

Multiple line comment start with /* and end with */

#include <iostream.h>

#include <conio.h>

 

Void main() {

 

Cout<<”this is a simple program”; 

 

 /* this

Is multiple

Line comment  */

 

}



Data science & data analyst

C++

Algorithms

Technology


Post a Comment

Ask any query by comments

Previous Post Next Post