Question: Write a program named Reverse.cpp that will display an initialized array of 3 4 doubles on the screen, reverse the order of the array's values,
Write a program named Reverse.cpp that will display an initialized array of doubles on the screen, reverse the order of the array's values, and then display the array again.
Create and use the following functions in your solution:
A function named init that initialized an array of any length. Initialize an array such that the first half of the elements are equal to the square of their index and the second half of the elements are equal to the square root of their index. To initialize the array, use a single index variable and one or two countercontrolled loops. The function should have two parameters: a reference to the array and a value parameter to get the array's sizelength
A function named display that displays an array of doubles of any size to the screen. The function should have two parameters: a constant reference to the array and a value parameter to get the array's sizelength The function should display eight elements per line with a newline at the end of the last lines even though it may not be a full elements Each displayed value should be rounded to decimal place. The output should be presented in a grid with rightaligned columns of equal width and with a minimum of spaces between the numbers see the example output below
A function named swap that swaps two values in an array of doubles located at two indexes The function should accept three parameters: the array, the index of the first element to swap, and the index of the second element to be swapped.
A function named reverse reverses the order of the values in an array of doubles. The function parameters should include a reference to an array and a copy of the array's size. The values of the array should be actually reversed. Do not put any cout statements within this function. Use a local variable temporary array called tmpArray to do the work of swapping, then copy the results into the parameter array before returning.
Hint: Start by swapping the first and last values in the array. Then, swap the second and next to the last values. Continue until you reach the middle.
Remember that arrays can only be passed by reference. Do NOT use the symbol & when declaring an array as a formal parameter. Any array parameter for a function that does not modify that array should be a constant parameter.
Sample Output no user input
The initial values of the array are: The values of the array after reversing them are:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
