a1
for the files for this assignment.
cd a1
to move into that directory.
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"); }
gcc -o first first.c
. The "-o first
" part tells the compiler to output the program into a file called first
.
./first
(Thescript a1.out pwd cat first.c ./first exit
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
.)
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.
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:
double
variable named radius
. Set this variable to 30.
double
variable named area
, calculate the area of a circle with radius radius
. This is done with the formula 3.1416 radius
2 .
radius
and area
. (They should be 30 and 2827.44.)
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):
Then, submit the filetar cvf a1.tar a1.out modify.c root.txt gzip a1.tar
a1.tar.gz
.
Return to CMPT 102 Assignments
Copyright Greg Baker, last modified January 2003.