Write a program that will display an array of 56 doubles on


Assignment

Write a program that will display an array of 56 doubles on the screen, reverse the order of the array's values, and then display the array again.

Create and use the following functions with meaningful names in your solution:

• A function to set the value each element in an array of any length. Initialize an array such that first half of the array are random numbers between 0 and 1. Each element in the second half of the array must be equal to the square-root of their index. To initialize the array, use a single index variable and one or two counter-controlled loops. Make sure that the random numbers are different every time you run the program.Hint: To get a random number between 0 and 1, convert the random number to a double and then divide by RAND_MAX, which is a constant defined in the cstdlib that is the maximum value returned by the rand function.

• A function that prints an array of doubles of any size to the screen. The function should display 10 elements per line. Each value should be rounded to 2 decimal places. The output should be presented in a grid with right-aligned columns of equal width. The function should have two parameters: (1) a constant reference to the array and (2) a value parameter to get the array's size.

• A function that swaps two values in an array of doubles (located at two indexes). The function should accept three parameters: (1) the array, (2) the index of the first element to swap, and (3) the index of the second element to be swapped.

• A function that 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. Hint: start by swapping the first and last values in the array, then swap the second and next to last values, and continue until you reach the middle. The values of the array should be actually reversed. Do not put any cout statements within this function.
Important Reminders:

• 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.

• Functions that accept an array should not assume the array is a particular length. If the function goes though the length of the array, pass the array length as a parameter.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Write a program that will display an array of 56 doubles on
Reference No:- TGS02705350

Expected delivery within 24 Hours