C++ COMMENTS

Comments are hints that a programmer add to explain code and make it more understandable.

There are two types of comments in C++ language:

1. Single Line Comments, &

2. Multi Line Comments.

Single line Comments :

Single-line comments Start with two forward slashes(//).

Any text are write after the forward slashes(//) then  the line is ignored by java(will not be executed).

Example:

//Program to add two numbers.

class Demo {
    public static void main(String[] args) {
  //Declaring and initilizing variables.    
  int num1 = 28;
  int num2 = 32;
  int sum = num1+num2; //adding both numbers in sum variable.
 
  //print the sum of num1 and num2.
  System.out.print("Sum: "+sum);

}

Multi-line comments:

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

Any text are write between /* and */ will be ignored by java .

Example:

/*Progrm in java to 
add two numbers.*/

class Demo {
    public static void main(String[] args) {
  //Declaring and initilizing variables.    
  int num1 = 28;
  int num2 = 32;
  int sum = num1+num2;
 
  //print the sum of num1 and num2.
  System.out.print("Sum: "+sum);

}