In C++ what is comment in c++ language.

                                                                                                                    COMMENT

 this is comment ,   





 

Comments are used by the programmer to make the code understandable so that is can be improvised later and to make it more readable. It can also be used to prevent execution when testing alternative code.

 

There are two ways to write Comments: singled-lined or multi-lined.

 

Single line comments

 

Single-line comments are initiated with two forward slashes (//). This comments the entire line after the two slashes.

 

Example:-





#include <iostream>

using namespace std;

int main() {

    // this is a comment won't be executed

    cout <<"this word will print";

    return 0;

}






 

Multi Line comments

 

Multi-line comments start with /* and ends with */

 

The text in between both of these will not be executed by the compiler. Hence comments can we written in multiple lines

 

Example:



#include <iostream>

using namespace std;

int main() {

    /* this is a multi line comment 

    which is not executed */

    cout <<"this word will print";

    return 0;

}







please try yourself this code so you can learn better way ,

thanks for reading this blog for comment .


Comments

Popular posts from this blog

In C++ Syntax

Add two number using class in c++ .

DATA types in C++ languages .