Read the complete assignment before you start.

Motivation

In this assignment you will have an opportunity to practice developing C programs that have functions.

Learning Outcomes

Completing this assignment, will allow you to

Format

May be done in pairs (groups of two) or individually. If done in pairs, both team members must make an individual submission and clearly indicate the name of the collaborator in both the submitted file and in a submission comment. The collaborators may submit the same code.

Prerequisistes

Prior to working on this assignment, review these lessons and refer to them during the assignment:

Materials & Tools Needed

Tasks

Read through all of the tasks first and then work through them in sequence.

  1. (5 pts) Create a new source file called LastNameF.CS5600.LearnC.c where LastName is your last name and F is your first name’s first letter, e.g., CooperMCS5600.LearnC.c.

  2. (5 pts) Add a proper header with your information, the name of the course, and the assignment title. (5 pts) Add a main() function and include all necessary header files.

  3. (5 pts) Create a makefile and ensure that it compiles your code. The resulting executable must be called CS5600.LearnC. Ensure that the executable runs.

  4. (60 pts) Create the following three functions that convert between mileage/efficiency metrics:

    1. mpg2kml() that takes miles per gallon as an argument and returns the equivalent kilometers per liter.
    2. mpg2lphm() that takes miles per gallon as an argument and returns the equivalent number of liter per 100 kilometers.
    3. kml2mpg() that takes the kilometers per liter and returns miles per gallon.
  5. (10 pts) Add some test cases to your main() function to test that the functions work. Display the results (from main() and not in the functions).

  6. (5 pts) Add some test cases to your main() to ensure that you functions work even when “bad” argument values are passed.

  7. (5 pts) Make sure that your functions have headers (look up common standards) and that your code is professionally documented and formatted.

Hints

Submission

Submit a single .tar file (LastName-CS5600.S23-LearnC.tar) that contains your source file and the makefile. Ensure that your program compiles and executes properly. Test carefully prior to submitting.


Useful Resources


References

None.


  1. Do not use a word processor to edit files↩︎