Commerits are added to make a program more readable but the compiler must ignore them The slash/star(/* ..*/) combination is ysed in C for comment delimiters Plcasc note that the program does noi illustrate good commenting praetice, but is intended to illustratc where comments can go in a program.lt is a very sloppy looking program.
The first slash star combination introduces the first comment and the star slash at the end of the first line line terminates this comment. Note that this comment is prior to the beginning of the program illustrating that a comment can prcccde the program itself. Good programming practice would inelude a comment prior to the program with a short
introductory description of the program. THEnext comment is aficr the main() program cntry point and prior to the opening brace for the program code itself. The third comment starts after the first executable statement and continues for four lines. This is perfectly legal because a comment can continue for as many lines as desired until it is terminated.Note earefully yhat if anything were included in the blank spaces to the left of the three continuation lines of the comment,itwould be part of the comment and would not be compilcd.The last comment.it would be part of the cimment and would not be compilcd.The last comment is located following the completion of the program.illustrating that comments can go nearly anywhere in a C program.
Experiment with this program by adding comments in other places to sec what will happen. Comment out one of the printf statrments by putting comment delimiters both before and after it and sec that it does not get printed out.
Comments are very important in any programming language because you will soon forget what you did and why you did it.lt will be much easier to modify or fix a well commented program a year from be much easier to modify or fix awell commentes program a year from now than one with few or on comments.You will very quickly develop your own personal style of commenting.Some compilers allow you to nest coments which can be very handy if you need to comment out a section of code during debugging; check your compiler documentation for the availability of this feature with your particular compiler.
Good formatting style
Here is an ecample [GOODFORM.C] of a well formatted program:
Page 813-7