CMPT 102 Assignment #1

Due January 24, 2002

Part 1

This part is intended for you to get aquainted with the computing resources for the course.
  1. Log in to one of the computers, either in the lab or remotely over the Internet.
  2. create a directory called a1 for the files for this assignment.
  3. cd a1 to move into that directory.
  4. Create a file called first.c which contains the following C code:
    /* My first C program */
    /* by (your name and student number) */
    #include <stdio.h>
    int main ()
      printf("Hello, world!\n");
  5. Compile this program with the command gcc -o first first.c. The "-o first" part tells the compiler to output the program into a file called first.
  6. Run this program by typing the command ./first
  7. If it works correctly, execute the following commands:
    script a1.out
    cat first.c
    (The script command copies all of the output that you see into a file that can be submitted. The cat command just dumps the file first.c onto the screen. Don't forget to exit.)
  8. Have a look at your a1.out file to make sure you actually have the right stuff in it. Type the command more a1.out. You should see a transcript of the commands you just typed.

Part 2

First, make a copy of your program from Part 1 named modify.c. You can do this with the command cp first.c modify.c .

Modify so that:

Part 3

Have a look at the "Engineering Problem-Solving Methodology" in section 1.3 of the text.

Consider the following problem: Given the coefficients of a quadratic equation, determine the number of (real) roots the equation has and what they are.

That's step 1 (state the problem). Do steps 2 and 3. For step 4, develop an algorithm to solve the problem and describe it with a "decomposition outline"; you don't have to write a program. Since you haven't written the program, you don't have to test it (step 5), but you should convince yourself that your algorithm works correctly.

Using an editor, create a file called root.txt in the a1 directory and type your answers for this part in there.


You have to use the Submission server to submit your work. You should submit the files a1.out, modify.c and root.txt.

You can do this by typing these commands (cd a1 if you haven't already):

tar cvf a1.tar a1.out modify.c root.txt
gzip a1.tar
Then, submit the file a1.tar.gz.

Copyright Greg Baker, last modified January 2003.