1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Lapatulllka [165]
3 years ago
8

Write a program that asks the user to input an integer named numDoubles. Create a dynamic array that can store numDoubles double

s and make a loop that allows the user to enter a double into each array entry. Loop through the array, calculate the average, and output it. Delete the memory allocated to your dynamic array before exiting.
Computers and Technology
1 answer:
Hitman42 [59]3 years ago
6 0

Answer:

Answered in C++

#include <iostream>

using namespace std;

int main() {

   int size;

   cout<<"Length of array: ";

   cin >> size;

   double *numDoubles = new double[size];

   double sum =0;

   cout<<"Array Elements: ";

   for(int i=0;i<size;i++){

       cin>>numDoubles[i];

       sum += numDoubles[i];

   }

   delete [] numDoubles;

   cout<<"Average: "<<sum/size;

   return 0;  

}

Explanation:

This line declares the size (or length) of the array

<em>    int size; </em>

This line prompts the user for the array length

<em>    cout<<"Length of array: "; </em>

This gets the input from the user

<em>    cin >> size; </em>

This dynamically declares the array as of double datatype

<em>    double *numDoubles = new double[size]; </em>

This declares and initializes sum to 0

<em>    double sum =0; </em>

This prompts the user for elements of the array

<em>    cout<<"Array Elements: "; </em>

The following iteration gets input from the user and also calculates the sum of the array elements

<em>    for(int i=0;i<size;i++){ </em>

<em>        cin>>numDoubles[i]; </em>

<em>        sum += numDoubles[i]; </em>

<em>    } </em>

This deletes the array

<em>    delete [] myarray; </em>

This calculates and prints the average of the array

<em>    cout<<"Average: "<<sum/size; </em>

You might be interested in
Compare the freedom available to the American media with the freedom available to media in other parts of the world. How does a
Rzqust [24]

in america we are free to say most of whatever we want in media becuase we have free speech here. in other countries, they don't have freedom of speech,and sometimes it also has to do with the political situation. like say in china, where teenagers arent allowed to use the internet for more than a certain amount of time,and arent allowed to talk to each other. thats becuase of the fact that that country is a communist country and the government wants much more control than in other countries.

6 0
2 years ago
One of the major disadvantages of application service providers (ASPs) is that they:
AVprozaik [17]

Answer:

do not guarantee that applications will fully meet an organization's needs.

Explanation:

An application service provider is a third-party group established to deliver commercial software applications and additional services related to such software and do so online and sometimes their services do not guarantee that their applications will fully meet an organization’s needs.

8 0
3 years ago
Under which menu would you be able to see the number of continuous track minutes available on each mounted hard drive at the cur
Crazy boy [7]

Answer:

looooollll

Explanation:

yooooooooo u good

3 0
1 year ago
:P 80 points to spare so i guess its free!!!!!!
Naddik [55]

Answer:

Thank you! can i have brainliest please?

Explanation:

5 0
2 years ago
Read 2 more answers
20 POINTS!!! I NEED HELPP
Cloud [144]

Answer:

Apple

Explanation:

5 0
3 years ago
Read 2 more answers
Other questions:
  • A(n) ____ loop executes a predetermined number of times.
    12·1 answer
  • If you print a document with red green or blue underlines will they show up on printed pages
    14·1 answer
  • In Microsoft Word you can access the _______ command from the "Mini toolbar
    11·1 answer
  • What is the mass of a cookbook
    7·1 answer
  • Maria is creating a program where the user will enter their name to begin. What kind of variable should be used for the user’s n
    15·2 answers
  • Describe two types of software suites supporting your answer with three examples each.
    12·1 answer
  • Super Scores
    11·1 answer
  • State the function of the <br> BIOS,​
    11·1 answer
  • Please answer fast..​
    15·1 answer
  • What is one of four key principles of Responsible Artificial Intelligence
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!