Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 6

HOW TO WRITE

COMMENTS IN C
PROGRAMMING

S A N D A R U WA N I PAT H I R A G E
B . S C . ( H O N S ) I N M A N A G E M E N T A N D I N F O R M AT I O N T E C H N O L O G Y ( O U K )
C O N S U LTA N T / L E C T U R E R – N I B M
What Is Comment In C Language?
A comment is an explanation or description of the
source code of the program. It helps a developer
explain logic of the code and improves program
readability. At run-time, a comment is ignored by the
compiler.
There are two types of comments in C:
1) A comment that starts with a slash asterisk /* and
finishes with an asterisk slash */ and you can place it
anywhere in your code, on the same line or several
lines.

2) Single-line Comments which uses a double slash //


dedicated to comment single lines
Why do you need comments?
A good programmer who writes codes understood by
a human is better than a programmer who generates
codes understood only by the machine.

So, it is highly recommended to insert comments to your


code because it is good programming practice.
Comments do not affect a program because the
compiler ignores them.
Comments help the developer understand the
logic/algorithm of the code if he revisits it after a long
time.

You might also like