CS 1711 Lab 5 - October 20 and 22, 1998
Writing Functions and Driver Programs

Writing a Driver

In this section you will get some practice at taking an exsiting function and writing a driver program to test it.
  1. Load the file LABSUB.CPP.
  2. The main function does nothing. Modify the main function to test the function get_first.
  3. Test the program at least 6 times and record which values you use for the test.
  4. Save the program.

Designing a function given the driver

In this section, you will be given a driver program and a function for which a stub has been inserted. You are to replace the stub with the real code for the function.
  1. Load the file MAXOF3.CPP.
  2. Try running the program to see the results.
  3. Modify the function so that the program works properly (you must NOT modify the main function).
  4. Save your program.

Call-by-value and Call-by-reference Parameters

The objective of this section is to point out the differences between call by value and call by reference. This section assumes that you have already read the section in the text on call-by-reference parameters. If you have not done so, now would be a good time to browse it.
  1. Load the file PARAMS.CPP.
  2. DO NOT RUN THIS PROGRAM! (yet)
  3. Look through the program and predict on a peice of paper, what values you expect to see when the program is run. Each section will output three numbers. Predict what will happen in each section.
  4. Now run the program and record the results.
  5. Did you score 100%? If you cannot determine why some of the actual outputs do not look correct, ask.

End of Lab

No, you are not missing the other side of the lab. This lab was purposely left short for a chance to review/preview the differences between call-by-value and call-by-reference parameters. If you have finished early, please use the time to work on the current assignment if you have not already finished it.