This assignment will give you practice compiling a project made from multiple source files, includes, and libraries.

The Task

Let's compile some C++. Write a program with these files:

  1. main.cpp - a program that uses printf to print the phrase "A table of values follows." and then calls the function table that takes 3 arguments: a start value, end value, and step. These values should be 0, 10, and 1. main should have return code of 0. The program must use the printf routine!
  2. table.cpp - a file that contains the table function that takes three doubles. It prints the functions f and g for the values of x from start up to and including finish in steps of step. See example output for formatting. It must use printf for its output.
  3. table.h - the header file for table.cpp. Be sure to include the include necessary for printf.
  4. funcs.cpp - a file that contains the two functions f and g. which each take a double and return a double. f must be defined over at least the closed range 0 to 100 and call the sqrt function. g must be defined over at least the closed range 0 to 100 and call the pow function. Your f and g functions can be any function you find interesting but they are required to call the functions listed above.
  5. funcs.h - a file that contains the header file for funcs.cpp.
  6. Create a makefile called makefile. It, by default, will build the project. It must do this by assembling the final executable from the .o files. Your makefile must not say how the .o files are built. Rely on make's smarts about creating .o files by compiling source files. If I edit one of the files it should build the appropriate .o and then assemble the executable. Do not make a dependency on a header file. All files must be compiled with the -g and -Wall options. The compiler must be g++.

    You must also provide a fake target of "clean" which will remove the .o files.

    You must also provide a fake target of "all" which will touch all the source files and then call make. Be sure that all your files include the right header files including for various system provided functions like printf or sqrt.

    Testing

    To test your code and better understand the definition of the functions there is a tar in the sidebar that contains a mock directory structure. Included is also a test script and the expected output when the test script is run in the same directory where the tar is exploded.

    Submission

    Homework will be submitted as an uncompressed tar file to the assignment in BBLearn when the assignment is ready there. See class news.

    Have fun.