Comments:

Comments are the lines of program that are not executed. The compiler ignores comments and does not include them in the executable program. That is why the comments do not affect the size of executable program.

Comments are used to increase the readability of the program. Comments are notes about different lines of code that explain the purpose of code. The user can insert information notes in the code. It helps in debugging and modifying the program later.

Comments can be added anywhere in the program or code.

Comments are of two types:

 

Single line comments

Comments on single line are added by using double slash “//”. Anything written on the right side of the double slash is considered as comments and is ignored during execution.

 

Multi line comments

Multi line comments are inserted to the code by placing /* at the beginning of the comments. The character */ is used to end the multi line comments.

EXAMPLES

Following line is an example of single line comment:

//practice makes a man a good programmer.

Another way to add comments on a single line is as follows:

/* these are also comments…*/

In order to add comments on many lines in program, following way is used:

/*these lines are

For the purpose of

Writing comments*/