How to give Comments in C++ Language !!
Every language will provide great feature which is used in source code. We can write more readable and eye catching program structure using comments. We should use as many as comments in C++ program. “Comment is non executable Statement” in the C++.
Types of Comment in C++ Programming
- Single Line Comment
- Multiple Line Comment
Single Line Comment
cout<
- Single Line comment starts with “//” symbol.
- Remaining line after “//” symbol is ignored by browser.
- End of Line is considered as End of the comment.
Multiple Line Comment in C++ Programming
#include
int main()
int main()
{
/* this comment can be considered as
multiple line comment */
multiple line comment */
cout << “Hello C++ Programming”;
return(0);
}
- Multi Line comment starts with “/*” symbol.
- Multi Line comment ends with “*/” symbol.
How to use Comment more efficiently
Comment for User Documentation.
Hiding Non-usable Code.
Hiding Single Statement.
Comment used to explain particular language statement
/* Name : Main Function
* Parameter : None
* Return Value : Integer
* Author: Vivek Kumar
*/
#include
#include
void main()
#include
void main()
{
cout << “Hello Vivek “;
getch();
}
- Comments are non Executable Statements.
- Comments are always neglected by compiler.
- Comments are replaced by white spaces during the preprocessor phase.
- Comments can be written anywhere and any number of times.
- Comments can be used for documentation.
- Comments can be Single Line or multiple line.