The best programs are self-documenting; their variable and
function names are well chosen and their algorithms clearly expressed.
These programs need few comment statements, if any.
In fact, having too many comments often makes the code harder
to understand. A comment which incorrectly describes your program
is worse than useless!
Don't use comments to say what a specific statement does --
i.e., assume your program reader already knows C. DO use comments
to explain how the specific parts of your program fit into the
whole, especially if you are doing something complicated or
non-standard. DO use white space (blank lines) to separate the
statements of your program into conceptual "paragraphs."
Use comments to make your functions more re-useable. Briefly
describe what the function computes (the function's post-conditions)
and what it assumes about its inputs (the function's pre-conditions).
For example, here is what I would put before the power
function:
/* power(x,n) returns x^n */
/* power assumes n >= 0, and returns 1 for n < 0 */
/* power(0,0) returns 1, you may disagree */