Question: Write a program in C++ that prompts the user to initialize an array of 8 integers based on user input. Then, the program should perform
Write a program in C++ that prompts the user to initialize an array of 8 integers based on user input. Then, the program should perform the following:
(1) Output the values of the elements of the array to the screen
(2) Output the array in reverse order to the screen
(3) Calculate the sum of the square root of each element
(4) Find the minimum element in the array
(5) Copy the elements of the array to another array and output the second array to the screen
A sample run of your program should look like this:
Enter 8 integers to initialize the array.
Enter element at position 0: 23
Enter element at position 1: 67
Enter element at position 2: 45
Enter element at position 3: 100
Enter element at position 4: 235
Enter element at position 5: 32
Enter element at position 6: 75
Enter element at position 7: 34
The elements of the array are: 23 67 45 100 235 32 75 34
The elements of the array in reverse order are: 34 75 32 235 100 45 67 23
The sum of the square roots for each element is: 65.17
The value of the smallest element is: 23
Enter your copy request.
Please enter how many elements you want to copy from the first array to the second array: 4
Please enter starting position for the first array: 2
Please enter starting position for the second array: 2
The elements of the second array are: 1 1 45 100 235 32 1 1 1 1 1 1 1 1 1
In order to copy the elements of the array to a second array, the program should prompt the user to enter the initial position from which the copying should start and the target position of the second array to which the copying should start. The user will also input how many elements he/she wants to copy (see sample run above).
The program should check if the boundaries of the arrays are sufficient before the copying starts. If the user request is not within any of the arrays' boundaries, the program should provide appropriate messages: "Cannot copy the elements because your request is not within the first array's boundaries" or "Cannot copy the elements because your request is not within the second array's boundaries".
The second array must hold up to 15 integers and all elements must be initialized with 1 before copying other elements to it.
The sizes of the arrays must be declared with variables.
You must use functions to perform the actions (1) to (5) (one function for each action) as well as to initialize the arrays.
The prompts displayed by the program must be formatted as shown in the sample runs (blank lines, spacing etc).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
