Comment is a statement of one or more lines written by the programmer to understand himself and others, what the code is all about.
Comments are declared in two ways :
- One line comments starts with double slash symbol "//" and terminates at the end of line.
- Two or more line comments starts with slash star "/*" and ends on same line or next lines with star slash symbol "*/".
- // this is one line comment
- /* this is
- a multiline
- comment */
- Comments are written by the user to understand the source code for himself and others.
- User can write comments any number of times in the program at any place.
- Its good to write comments to specify the reason for using a certain statement or expression.
- Compiler rejects these comments, so they didn't get added to the executable file.
Its very good habit of writing comments in a program.