The grade will be based on a scale of 100. Points will be based on both style and execution. Style will count 30 and execution will count 70. Lateness points will be subtracted after points have been subtracted for errors of style and execution. The remaining points will be recorded as the grade for the program. For example, if there are 10 points of style errors and 15 points of execution errors, the grade would be 75. If, however, the program is two days late, the lateness penalty would be 20%, and the grade would be 75-20 = 55. The schedule for lateness is given with your first programming assignment.
Here are some guidelines for the two categories, style and execution.
Style 30 points. Style consists of comments,
mnemonic variable names, and indentation. The purpose of
good style is to make the meaning of your program clear to someone
who has never seen it before, cannot run
it, and cannot talk with you.
// CIS 303, Section 1, Fall 1999, Programming Assignment 1 // Author: Ima Student // Purpose: Print ten approximations to a square root. // Usage: The user types in one positive number. It need not be an integer. // Method: The user is prompted for the number. A first approximation // is made by .... A for loop is used to .... Each approximation .... ////////////////////////////////////////////////////////////////////////////////There should be comments alongside the definition (or declaration) of every variable.
const char control_z = 26; // ASCII code for control-z
char input_char; // input character
float key[]; // If the comment that goes with the declaration
// requires two or more lines, do it this way.
int i; // counter for input while loop
int numeric = 0; // 1 if numeric sort, 0 if alphabetic
Interspersed within the C code there should be comments wherever there are statements or expressions
that would be difficult to understand by a C programmer. Otherwise no comments are necessary. Here
are examples of unnecessary comments:
s[i++] = c; // set s[i] to c and then increment i
sign = ( s[i] == '-' ) ? -1 : 1; // Set sign to -1 if the character s[i]
// is a minus sign, or +1 otherwise.
The comments are of two types. The first type of comment is written on the same line with a statement
explaining that statement. The comments with the declarations above are examples. Here are examples
for executable statements:
for ( i = 0; isspace(s[i]); i++ ); // skip white space mask = 0xC0; // set bits 6 and 7 high, all others lowThe second type of comment is written on a line or lines by itself and explains the following statement or block of statements. It should be indented the same distance as the statements following it. Here are some examples:
// Determine the net worth of each player by subtracting liabilities from
// assets.
for ( player = 1; player <= number_players; player++ )
{
...
}
// The following loop counts the number of contiguous groups of
// equal numbers in the list and the number of pairs that differ by 1.
for ( i=0; i<size; i++ )
{
if ( item[i] == item[i+1] )
{
number_of_groups++;
...
}
else
{
...
}
differ = FALSE;
}
Execution 70 points. Execution consists of two parts:
(1) correct results and (2) efficiency and appropriateness:
Perhaps the most important aspect of appropriateness is the degree to which the program is appropriately "modularized". A program is modularized appropriately when clearly identifiable tasks are implemented as separate functions. You will not be able to modularize your programs until you learn how to write and call C functions.
External variables should never be used except as specified by your instructor. (An external variable is one that is not defined inside any function.)
The goto statement should never be used unless specified by your instructor.