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
1. Style comments
This page has style comments.
Going forward, A3 and after, these (and other) deductions will be made.
2. Multiple blank lines
Avoid multiple blank lines in program code. The extra blank lines are not needed.
"0 avoid multiple blank lines in program code": 14
"0 extra blank lines not needed": 2,
3. Output statements
"0 in printf, use \t for leading indentation instead of spaces": 1,
4. Comments
"0 multi-line comments should have /* and */ on separate lines": 4,
/*
This is a good
multi-line comment form
*/
/* This is a not good
multi-line comment form */
// This is a good single line comment form
//This is a not good single line comment form
Only include comments that add value to the reader. The reader understands C, and understands the problem.
"0 not good comments - breaks up the pattern - it is obvious what the program does without the comments": 1,
Good comment: (no comment)
double map_distance;
Not good comment: (not needed, obvious)
// this is the map distance
double map_distance;
5. Header comments
"0 be specific on what type of help received": 1,
"0 for help, use none, not N/A": 1,
"0 remove parentheses in header comments": 10,
"0 remove parentheses in help author, etc.": 1,
"0 pseudocode should be on separate lines": 2,
6. Variable names
"0 uppercase names are for constants": 1,
Use meaningful names for most variables.
A variable name should always refer to what it represents.
7. Indentation
"-1 minor indentation issue - sequence of statements should be at same indentation level": 8,
"-2 major indentation issue - sequence of statements should be at same indentation level": 3,
8. Indentation rule
Rule:
On a left curly brace "{" every line after is indented one tab stop.
On a right curly brace "}", every line after is undented one tab stop.
Do not mix tabs and spaces in the left white space indentation.
...
... {
...
... {
...
}
... {
...
}
}
...
9. Customer facing input and output
All customer-facing input and output should match exactly the provided input and output examples. This constitutes the functional requirements.
"-4 do not change customer-facing input/output text - moderate changes": 5,
"-6 do not change customer-facing input/output text - major changes": 7,
"-6 do not change customer-facing input/output text - major changes": 8,
"-2 do not change customer-facing input/output text - minor changes": 15,
"0 do not change customer-facing input/output text - trivial change": 5,
10. Specific requirements
Some works have very specific requirements and deductions specific to that work.
"0 upper case L should be lower case l": 1,
"0 Uppercase K should be lowercase k": 1,
"-6 missing last name": 3,
"-6 missing points of the trapezoid": 3,
11. Minimal code
In a good program, everything there is needed and important.
Anything not needed should be removed.
int i1 = 0;
// code not using i1
i1 = 10;
In the above code, variable
i1 is declared and initialized to
0. But then it is set to
10. So a better way would be as follows, where declarations are separated from input/processing.
int i1;
// code not using i1
i1 = 10;
12. Input using scanf
scanf("%d,%d", &x1, &x2);
good: (accepts any double number)
double x1;
scanf("%lf", x1);
not good: (only accepts numbers with two places past the decimal point)
double x1;
scanf("%0.2lf", x1);
good: (reads two double numbers)
double x1;
scanf("%lf %lf", &x1, &x2);
not good: (comma is required in the input, else second value becomes
0.0)
double x1;
scanf("%lf,%lf", &x1, &x2);
13. Strings
Declare string
s1 and (single) character
s2.
char s1[256], s2;
Declare (single) character
s1 and string
s2.
char s1, s2[256];
Declare string
s1 and string
s2.
char s1[256], s2[256];
14. End of page
15. Multiple choice questions for this page
9 questions omitted (login required)