------------------------------------- Spacing Sample #1: ------------------------------------- int main( void ) { int x = 0; if( x < 0 ) /* If X is Negative */ printf("Less than 0"); else if( x == 0 ) /* If X is Zero */ printf("Equal to 0"); else /* If X is Positive */ printf("Bigger than 0"); return 0; } NOTES: 1. These comments are on the same line as the conditional test 2. Decide whether this is better than the next one 3. I've got all the comments lined up with one another. ------------------------------------- Spacing Sample #2: ------------------------------------- int main( void ){ /* Variable: X -- indicates a positive, negative or zero value */ int x = 0; /* If X is Negative */ if( x < 0 ) printf("Less than 0"); /* If X is Zero */ else if( x == 0 ) printf("Equal to 0"); /* If X is Positive */ else printf("Bigger than 0"); /* Ending Program */ return 0; } NOTES: 1. These comments are all on their own line 2. Decide whether this is better than the previous one 3. I've got the comments aligned with the same context-level as the statement to which they apply. See the page on Style. ------------------------------------- Spacing Sample #4: ------------------------------------- int main( void ) { int x = -5; /* While Loop: Executes while X != 8. */ /* Each execution of the loop increments x by 1 */ while( x != 8 ){ if( x < 0 ) /* If X is Negative */ printf("Less than 0"); else if( x == 0 ) /* If X is Zero */ printf("Equal to 0"); else /* If X is Positive */ printf("Bigger than 0"); x++; /* Incrementing x by 1 */ } return 0; } NOTES: 1. There's a blank line between the variable declarations and the while statements. 2. There's another one between the conditionals INSIDE the while statement and the x increment line. 3. There's another one between the closing brace for the while and the return statement. 4. Comments are on the same line as the applicable statement. ------------------------------------- Spacing Sample #5: ------------------------------------- /* Beginning Program */ int main( void ){ /* ///////////////////////////////////////////////// // Variable Declarations ///////////////////////////////////////////////// */ /* X indicates a positive, negative or zero value */ int x = 0; /* ///////////////////////////////////////////////// // Main Body of Program ///////////////////////////////////////////////// */ /* If X is Negative */ if( x < 0 ) printf("Less than 0"); /* If X is Zero */ else if( x == 0 ) printf("Equal to 0"); /* If X is Positive */ else printf("Bigger than 0"); /* Ending Program */ return 0; } NOTES: 1. Comments are on their own lines 2. Sections of main are indicated by large comments.