Comment in c++:
Comments are the part of source code.
Comments are for the programmer not for compiler. Anything in the comments
ignore the compiler do not run . the purpose of comments inserts description
within the source code. The comments could be line by line or whole block.
Line by line comment
It
starts from pair of slash sign(//),discards everything from where the pair of
slash signs (//) is found
up to the end of that same line.
For example.
Int a=2; // variable a is
declare by integer type which is initialize by value 2
Here “ int a=2;”
is the instruction which is run by compiler and “// variable a is declare by integer type
which is initialize by value 2” is comment which will be ignore by compiler.
Block comments:
Discards everything
between the /*characters
and the first appearance of the */ characters, with the
possibility of including more than one line.
For example:
/* my
second program in C++ with more comments
my name is umer and I am owner
of programminglogic.net */
#include
<iostream>
using
namespace std;
int main ()
{
Int a=2; //
variable a is declare by integer type which is initialize by value 2
……………….
………….
………………
}
Note:
If you include comments within the source code of your
programs without using the comment characters combinations //, /* or */, then compiler will take it as c++
code and it will generate the error.
0 comments:
Post a Comment