Comment In C++


Comment use for the description of the program. When we don’t want to use some code then we can also comment there


Why use Comment


Suppose you have 100 line of code temperorely you want to use 10 line of code then you will remove 90 line of code but Suppose next time you need that code then you will have to type 90 line of code again. That’s while we use comment.


How can i use Comment in C++


There are two way where we can use Comment


Single line comment


Single line comment use for single line of code Example


#include <iostream>

using namespace std;

int main(){

//Sum of two number and this line is commented here

int x=10;

int y=20;

int s;

clrscr();

s=x+y;

cout<<“The sum of two Number is”<<s;

return 0;

}


Output:
The sum of two Number 30


Multi line comment


Multi-line comment use for multiple lines of code. When we to skip the multi lines of code then we can use multi-line comment.


Example


#include <iostream>

using namespace std;

int main(){

/* Sum of two number and this line is

int x=10;

int y=20;

int s;

clrscr();

s=x+y;

cout<<“The sum of two Number is”<<s;

return 0;

}


Output:
The sum of two Number 30


We are using here mult line this type /*---------*/ b/w this block everything commented and that code will not executable.