Almost every time the teacher
gives lesson in school, we might copy everything from
the board or make notes over what is taught. There is
a similar thing we call in c++, ‘Comments’.
Comments can be used for different purposes.
The most obvious one, to recall the
purpose of the code (Say you are referring to it after
6 months, makes less sense then. If you don’t
include a comment.)
Helps your computer teacher know what
you have actually written. Just kidding.
Now this one is an unobvious reason.
Sometimes after compiling you might want to
remove some line just to see how your program works
then, without deleting the actual code.
The final one, just a good programming
style to express your thoughts.
Comments can be written anywhere
in the program (Good Feature). They don’t effect
your code, unless you comment out something by
There are two types of comments:
You can write anything that
makes sense here */
After the introduction of c++ it
just become a norm for programmers to ‘Comment
out’, huge parts of their code using this style.
The initial part (/*) and the final part(*/) can be on
“ This whole line gets, commented
The numbered indentation is not to be included with
the code while typing. It is only for your
After the 2 slashes, you can
type anything that makes sense.
This comment style is used more
often these days but please note that if your comment
sentence goes over many lines, please use // on each
line at the beginning.
“How are you I am fine”;
Line 4 will print
are you I am fine, to the screen.
placed the 2 slashes on this line too.