Question: In C++ This lab will do more with functions, focusing on reference parameters 1) The provided reorder.cpp file has some code for a function that
In C++
This lab will do more with functions, focusing on reference parameters
1) The provided reorder.cpp file has some code for a function that reorders the values in 3 parameters so that they are in ascending order.
Start with a function void swap(int &val1, int &val2) that swaps the values of val1 and val2. You will need a local variable to hold the value of one of the parameters to let you do this.
Write the reorder function called in main(). It should call swap() to exchange values when appropriate.
Add statements to main() to be able to try out the 3 cases below
Driver to test reorder()
Case 1: values are already in correct order -- leave them alone
1 2 3
Case 2: first > second and first < third
-5 -2 0
Case 3: first > second > third
6 8 10
2) Create a file cmpfiles.cpp. Write a function bool wordByWord(ifstream &text1, ifstream &text2) to see if the two files are the same when you compare them word-by-word. Write a driver to test the function using the sample files provided. To get true and false in the output, add #include
orig == samewords: true
orig == shorter: false
shorter == orig: false
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
