Excercise 02: Fix Programs Exercise

For this assignment you will follow a similar workflow to the Hello, CS110! activity. First, accept the assignment from the GitHub link in Moodle. To start working, clone the repository for this assignment into the directory that you created for this class (your cs110 directory).

Program One

This repository contains two files: program_one.c and program_two.c. Start by opening program_one.c in your text editor.

This program contains a number of errors. Before you start fixing the errors, try compiling the program. Make sure you have entered the directory for this assignment in the terminal using cd and then run the following command:

$ gcc program_one.c -o one

The compiler should complain about a number of errors. If gcc tells you that the file does not exist, you are likely in the wrong directory in the terminal. Refer back to the instructions for the in class activity about using cd to change directories.

Now try fixing the program and re-running the above command. You will know that the program compiled successfully if there is no output from the command. Make sure to remember to save your program in your editor before you compile!

If the program compiled, it will have produced a file named one, since we specified the name of the file to create with -o one. You can now run the program with this command:

$ ./one

Hopefully the program produced the output you expect. If not, go back and try to fix the program again, re-compile the program, and try to run it again.

Program Two

Now open program_two.c in your editor and fix that program as well. Be sure to compile and run the program to make sure it works before you submit. You will need to adjust the compile command so that you are compiling program_two.c instead of program_one.c.

Submission

Once your programs are working correctly, commit and push your changes using git like this. To add changes to multiple files you can either run git add twice (once for each file) or you can run git add once and give it both filenames like this:

$ git add program_one.c program_two.c

To commit:

$ git commit -m "Fix programs"

And to push:

$ git push

You can run the tests locally on your computer with the commands:

make gh-test-one

or

make gh-test-two

for program one and two respectively.

Once you submit your assignment to GitHub, check the result of the GitHub tests to make sure you are still passing the tests. If there were errors, fix your program again, test it, and submit again.

Grading - 10 points