Link back to syllabus

Makefiles

  1. Skim this introduction to Makefiles: http://www.cprogramming.com/tutorial/makefiles.html

  2. Write a Makefile suitable to compile two files, main.c and func.c into an application app. Test your Makefile by writing a short program with a function call (it can do anything you like – perhaps just add two numbers) spread into these files. The Makefile we developed in class this week is available.

Unit testing

You may wish to refer back to the examples listed next to class 4 from our syllabus.

  1. In (a new file) reverse.c, write a function int reverse_digits(int n) that reverses the order of digits in a number.

  2. Write a corresponding reverse.h that declares the reverse_digits function.

  3. Write a check_reverse.c file that runs unit tests on the reverse_digits function.

  4. Compile and check your work.

When you’re all done, post your work in a folder you create in our lab03 folder on GitHub.

Debugging

  1. Skim this introduction to GDB: http://web.eecs.umich.edu/~sugih/pointers/summary.html

  2. Peruse this GDB reference card.

  3. Use gdb to learn more about the behavior of your attempt at problem 6 on hw02. Work with your partner on this, debugging one submission together.

Magic squares

  1. Write a program that uses a 2d array to check if a square is a 3x3 magic square. The program should read in 9 numbers, build a square from these numbers, and check that it has the magic square property—that is, that every row, column, and major diagonal all sum up to the same number. (You do not have to check to make sure that all numbers are different or that the numbers go from 1 to 9. But you can if you want to!)