When you write code for programming assignments, you should include comments. A comment looks like this: /* this is a comment */ It is text preceded by a slash and an asterisk and followed by an asterisk and a slash. The compiler will ignore everything between the slashes. The purpose of a comment is to make your code more readable by a human.When you program, when and how to comment your code is a personal decision. It does not affect the "right-ness" of your programs. However, when you are programming assignments that will be read by someone else, it is important that you comment your code in a way that makes it easier to read for that person. In particular, for this course, your preceptor may have specific guidelines about when and how to comment. If you are in my precept, here are some general guidelines:
for (i = 0; i < 10; i++)
{
sum = sum + i;
}
a bad comment would be:
/*this loop initializes i to 0 and it repeats while i is less than
10 and i increases by 1 each time and each time through the loop,
you add i to sum */
That comment is bad for several reasons: it's long and wordy &
it doesn't tell you anything that you can't see by reading the
code. A better comment for this loop might be:
/* computes sum of all integers from 0 to 9 */
Try to write comments that describe the intention of the code.
Don't worry too much about your comments. I'll give you feedback on your first couple of assignments if I don't like how you're writing them.