Labs are due at 11:59:59 PM Tuesday nights. You must perform your labs alone. Obviously, you may talk about your labs with the TA's and with other students, but when it comes time to code, you must write your own code. Otherwise, it is plagiarism.
A corollary of this is to protect your directories so that no one can read them. If you do all of your work in ~/cs302, then right now, do:
UNIX> chmod 0700 ~/cs302If someone cheats off of you, chances are we cannot determine that, since file access times can be modified. In the past, when I have discovered cheating, both parties (cheater and cheatee) get zeros. Protect yourself.
if (i == 0) { /* If i equals zero */
return; /* then return */
} else { /* otherwise */
exit(1); /* exit with a value of one */
}
The above is an extreme example, but don't let it happen to you.
Here's an example of what I would consider a well documented program:
#include <stdio.h>
/* sumnsquared.c
Jim Plank
August 23, 1998
This program prompts for and reads a value n from standard
input, and then calculates and prints the sum of squares
from one to n. It uses a for loop instead of using the
closed form expression.
*/
main()
{
int n; /* The value */
int sum; /* The running sum of squares */
int i; /* An induction variable */
/* Prompt for and read in a value of n */
printf("Enter a value n: ");
fflush(stdout);
if (scanf("%d", &n) != 1) {
exit(1);
}
/* Calculate sum for each value of i from one to n */
sum = 0;
for (i = 1; i <= n; i++) sum += (i*i);
/* Print the final summation */
printf("%d\n", sum);
}