Send
Close Add comments:
(status displays here)
Got it! This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.nbsp; Note: This appears on each machine/browser from which this site is accessed.
Style comments: more
1. Style comments: more
Use one printf statement for each line of output (unless refactoring the output).
Use one scanf statement for each line of input.
When a constant (defined literal), such as
M_PI, is available (in the
math.h library), use it. Do not make your own approximation.
Do not extend code or comments too far to the right. All text should reasonably fit on a editor screen width.
"-1 use M_PI, not approximation": 2,
2. If statements
After a keyword, such as
if, there should be one space, and another space before the opening brace, and spaces on either side of operators.
good:
if (i1 == 7) {
}
not good:
if(i1==7){
}
bad:
if (i1 =7) {
}
else {
}
The above statement will assign the value of
7 to variable
i1 and return
true so that the
else part will never be executed.
3. Else parts
Some people use the following for the
else part using "
}else{" (no spaces).
if (Condition) {
...
}else{
...
}
This comes, in part, from the Google Go programming language where this form is required.
If you use this form, be consistent and use it everywhere.
4. End of page