Question: In C++ please Write a program that asks the user to enter an integer to create an array of size n. Use the value to

 In C++ please Write a program that asks the user to
In C++ please

Write a program that asks the user to enter an integer to create an array of size n. Use the value to create an n-element dynamic double array by allocating memory appropriately and hooking up a pointer to the array. Then allow the user to enter a double value into each array entry. Loop through the array, calculate the average, and print the result. Delete the memory allocated to the dynamic array before exiting the program. Specifications: You may not use vectors to solve the problem. Allocate and deallocate memory with the new and delete commands, respectively, and use a pointer to point to the allocated array of memory locations Format the output to 2 values after the decimal point. If you execute the program, the following information should be displayed main.o Enter size of the dynamic array: 3 Enter Element 1: 6.0 Enter Element 2:7.9 Enter Element 3:8.2 The average is 7.37 main.o Enter size of the dynamic array: 10 Enter Element 1: 6.0 Enter Element 2: 7.9 Enter Element 3: Enter Element 4: -3.4 Enter Element 5: -2.7 Enter Element 6: 7.2 Enter Element 7:1. Enter Element 8:0.6 Enter Element 9: 12.7 Enter Element 10: -4.9 The average is 3.34

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!