CS140 -- Labs


Helpful Documents

  1. gdb--C debugger
  2. vi--text editor

Lab Assignments

Lab Due Date Grading Guide Status
Lab 1
  • Fri Lab: 11:15AM, Friday, Sept. 12
  • Mon Lab: 2:30PM, Monday, Sept. 15
guide Ready
Lab 2
  • Fri Lab: 11:15AM, Friday, Sept. 19
  • Mon Lab: 2:30PM, Monday, Sept. 22
guide Ready
Lab 3
  • Fri Lab: 11:59PM, Friday, Sept. 26
  • Mon Lab: 2:30PM, Monday, Sept. 29
guide Ready
Lab 4 and sample Part 1 design document and Part 2 design help
  • Fri Lab Due Dates
    1. Design Document for Part 2: Friday, Oct. 3
    2. Part 1: Wed., Oct. 8
    3. Part 2: Fri., Oct. 17
  • Mon Lab Due Dates
    1. Design Document for Part 2: Monday, Oct. 6
    2. Part 1: Wed., Oct. 8
    3. Part 2: Mon., Oct. 20
guide Ready
Lab 5
  • Fri Lab Due Dates
    1. Design Document: Tues., Oct. 21, at beginning of class
    2. Fri., Oct. 24, at beginning of lab
  • Mon Lab Due Dates
    1. Design Document: Thurs., Oct. 23, at beginning of class
    2. Mon., Oct. 27, at beginning of lab
guide Ready
Lab 6
  • Fri Lab Due Dates
    1. Design Document: Fri., Oct. 24, at end of lab
    2. Fri., Oct. 31, at beginning of lab
  • Mon Lab Due Dates
    1. Design Document: Mon., Oct. 27, at end of lab
    2. Mon. Nov. 3, at beginning of lab
guide Ready
Lab 7
  • Fri Lab Due Dates
    1. Design Document: Fri., Oct. 31, at end of lab
    2. Fri., Nov. 14, at beginning of lab
  • Mon Lab Due Dates
    1. Design Document: Mon., Nov. 3, at end of lab
    2. Mon. Nov. 17, at beginning of lab
guide Ready
Lab 8 and design answers
  • Fri Lab Due Dates
    1. Design Document: Fri., Nov. 14, when the TA asks for it
    2. Fri., Nov. 21, at beginning of lab
  • Mon Lab Due Dates
    1. Design Document: Mon., Nov. 17, when the TA asks for it
    2. Mon. Nov. 24, at beginning of lab
guide Ready
Lab 9 and design answers
  • Fri Lab Due Dates
    1. Design Document: Fri., Nov. 21, when the TA asks for it
    2. Wed. Dec. 3, at 11:59pm.
  • Mon Lab Due Dates
    1. Design Document: Mon., Nov. 24, when the TA asks for it
    2. Fri. Dec. 5, at 11:59pm.
guide Ready


Lab Sections

Date Room
Monday 2:30-5:30Claxton 103
Friday 11:15-2:15Claxton 103


General Stuff

Lab attendance is mandatory for the entire time of the lab, unless you have already submitted the lab. If a lab is a multi-week lab you must attend each lab until you complete and submit the lab. In the past I have not made lab attendance mandatory beyond the beginning of lab but I have found that too many students do not budget their time well, procrastinate, and do not make any meaningful progress on the lab. Thus it is required that you attend and work on the lab during the lab period. If you have a time conflict throughout the semester (e.g., a class conflict) that does not allow you to attend the entire lab period please get an excused absence from me.

Labs are due at the same time, regardless of the lab in which you are enrolled. The TA's will let you know how to submit your lab work.


Late Labs

You can submit your lab up until 3 days after the due date but 10 points per day will be deducted from your final score.


Design Documents

You will be required to submit design documents that describe the high level design of your program, including key observations about how you can attack the problem, pictorial diagrams of your data structures, the structs you will use, and the test cases you will consider. The key observations section should explain why you are selecting various data structures to represent your data and explain at a high-level, how you plan to solve the problem. A sample design document can be found here.


Making Your Code Readable

In the real world your program will not be a one-and-done affair like it is in this course. Instead other people may have to maintain it after you have moved on to other projects. You therefore want to always strive to make your code as readable and well-organized as possible. Two techniques that help improve the readability of your code are good comments and meaningful variable names. You will be graded on both commenting and the variable names you choose. Something like 15%.

Variable names should reflect the purpose of the variable. For example, suppose I want to save the index of the minimum value I have seen thus far in an array. I could choose a meaningless variable name like m that will convey no information to a reader. A more meaningful name would be min but it still lacks clarity. Is it a minimum value, a minimum index, or some other min?. A meaningful name would be min_index or min_index_thus_far. It certainly takes more time to think up and type meaningful variable names but it is a good habit to get into.

You should comment your code by blocks of comments at the beginning of your files, and before subroutines. Variables should be commented inline. You may also want to comment large blocks of code. You should not comment with a ``running commentary'' to the right of your code, because that is often useless, hard to maintain, and disconcerting. I have seen comments like the following:

  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);
}