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.
- Load the file LABSUB.CPP.
- The main function does nothing. Modify the main function
to test the function get_first.
- Test the program at least 6 times and record which values you use for
the test.
- 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.
- Load the file MAXOF3.CPP.
- Try running the program to see the results.
- Modify the function so that the program works properly (you must
NOT modify the main function).
- 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.
- Load the file PARAMS.CPP.
- DO NOT RUN THIS PROGRAM! (yet)
- 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.
- Now run the program and record the results.
- 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.