C allows you to insert comments into your programs. A comment is a
message for the people who read your program. The C compiler completely
ignores all of the comments that you put in your programs.
Take a look at our C program. How do you think you write comments in C?
Click here for the answer.
In C programs, blank lines are like comments--they are ignored by the
compiler. Blank lines are included to improve readability, just as when
writing English.
Look through the program and identify the comments. Be sure that you can
identify where each comment starts and ends.
Comments are Very Important!
It is very important to put comments in your programs! Remember that every
time you write a program, you have two different audiences:
- The computers that will have to run your program; and
- The people that will have to read and understand your
program.
In every program it is important to include comments in order to summarize what
the program does, who initially created it, and who subsequently modified it.
For small programs this may seem tedious and pedantic, but it is essential for
larger programs so it's a good habit to learn. It should be possible to tell
what a program does (though not necessarily how it does it) by reading the
comments at the beginning of a program.
Eric N. Eide
Hamlet Project
Department of Computer Science
University of Utah