CS 112a
Fall 2000
Ileana Streinu

Lecture 3


  • Simple function calls in C. The swap function. Parameter passing in C and in C++. References versus pointers, a first example (we'll get back to this topic, in more detail, later in the semester).
  • Brief review of arrays in C and C++.

    Today: Hands-on lab, array applications and preparation for Hw3

    Reading: Game of Life handout.
    The goal of this lab is:

    To do

      Write C++ functions for (as many as you can of) the following tasks:
    1. Read a game of Life configuration from user input.
    2. Print a Life configuration on the standard output.
    3. Count the number of cells which are alive in a given Life configuration.
    4. Copy a Life configuration in another array.
    5. Given two Life configurations, compare to see if they are the same.
    To test this functions, you will write a main program which asks the user what to do, then depending on the choice, will execute one of the preceeding functions or quit. The options should be:
    Hint: start by writing the main program and provide empty functions for the 5 desired ones. Then implement each function, one by one, in the logical order which will allow you to test them.

    Submitting

    You should develop your program in stages, keep intermediate versions and submit the latest working version in Lab5, before leaving the lab at 10:20. Name the file lab5.cpp and submit a typescript, too.

    You should comment your program, write on it the names of both lab partners, if you didn't work alone, and relax: the lab will not be harshly graded. I want to see what each of you (or teams) can do when working under time pressure.

    After the lab: you can continue working and thinking about ways of completing this lab, but do not submit anything. You continue in the next lab, when again, you will be doing all the work in a limited amount of time and submit it by 10:20.