Exercise 01 - C Compilation

Out: Monday January 8, 2018
Due: Wednesday January 10, 2018 by 11:15am.

  1. Fetch the source files, main.c, sub.h, sub.c, and makefile (or just the file ex01.tar.gz).

  2. Build an executable from the source code using the makefile. (Just say 'make'.) Note that it builds without error.

  3. Run the executable you just created: ./ex01
    Note that it gets what seems to be a wrong answer (2 to the power 4 isn't 1).

  4. Figure out why.

  5. Hand in to the course dropbox a pdf file listing your name and
    • a brief (one or two sentence, say) description of what the problem was
    • explain how you could fix the executable by modifying only sub.h
    • explain how you could fix t he executable by modifying only sub.c
    • explain how you could get the compiler to complain that something is wrong by modifying only sub.c
    • can you fix the problem by modifying only main.c? Briefly explain.

  6. Don't hand in any code.