Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Relational Model A Retrospective Review And Analysis

Authors: C. J. Date

1st Edition

0201612941, 978-0201612943

More Books

Students also viewed these Databases questions