LAB EXERCISE A and B
FUN2 Exercise A and B
Exercise A:
1. The program will be working with pairs of data, first two integers, then two doubles. The lesson will use examples from the Lesson 7A regarding function overloading and function templates.
2. Write overloaded functions to get two values from the keyboard and return these values to the formal parameters using reference parameters. Function main will declare two integers and two doubles. When data is needed for these variables in function main, the function get2Values will be used to fill such variables. This function get2Values should be overloaded to work with integers in one case, and doubles in the other.
5. Function main should consist of this script of events:
a. Declare two integers and two doubles.
b. Use the overloaded function get2Values to load the two integers.
c. Use the overloaded function get2Values to load the two doubles.
d. Use the overloaded function print2Values to print the two integers.
e. Use the overloaded function print2Values to print the two doubles.
6. Whenever a pair of values is printed to the screen, include some informative introduction of the values. Example:
The two integers before swapping: 2 5
7. Turn in the source code and a run each function 2x using two different sets of input and output for the program. Turn in the sources code and both outputs.
16. Write a function swap as a templated function. This function will swap the contents of the two memory locations passed to the reference parameters. Place your code before your function prototypes.
Exercise B:
1. Add to execise A a templated function swap to swap the two integers.
a. Use the templated function swap to swap the two doubles.
b. Print the two integers again.
c. Print the two doubles again.