Question: C++ PROGRAM Write a template function called MoveToTheBack() which takes as arguments an array and its size (number of cells). The function moves the largest
| C++ PROGRAM Write a template function called MoveToTheBack() which takes as arguments an |
| array and its size (number of cells). |
| The function moves the largest value of the |
| array to the end of the array. |
| The way to do this is to take a pair of cells, and if cell k |
| is larger than cell k+1, switch them around. |
| Some other values may get moved around the array. |
| The function also returns the number of "pair switches" made. |
| In main declare three arrays with the given values in the order shown: |
| integer array with values: 3, 5, -1, 4, 2 |
| float array with values 2.1, 0, 3.5, 2, 2 and 1 |
| character array with values "fabs" |
| Include a template Display function which displays each array when called, with a |
space between each value
Here is sample output
3 moves for ints
3 -1 4 2 5
4 moves for float
0 2.1 2 2 1 3.5
2 moves for chars
a b f s
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
