CS120
Lab Assignment #13

Due at the end of your lab session.

This is a two part lab covering pointers.

For the first part of the lab you will be attempting to create three different functions that each swap the value of two floating point variables. The first function should have two floats as arguments (the return type is up to you). The second function should have two pointers to floats as arguments (the return type is up to you). The thrid function should have two pass-by-reference floats as arguments (the return type is up to you).

The code in main() should look (roughly) like the following:
float x = 7;
float y = 17;
cout << x << " " << y << endl; // to show the initial values
// call the swap function
cout << x << " " << y << endl; // now the values should be reversed

The prototype for the first swap function should be:
? swap1(float, float);
The prototype for the second swap function should be:
? swap2(float *, float *);
The prototype for the third swap function should be:
? swap3(float &, float &);
where you may choose the return type that replaces the ?.

Include all three functions in the same main program. Include a comment at the beginning of the program, after your name, etc. explaining which functions, if any, didn't work and why not.

For the second part of the lab you will be using a pointer to access the elements of an array. Add the new code onto the code from the first part of the lab so that you only have one program to turn in.

Turn in: Turn in the program, with comments, using cscheckin.