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
In symmetric key cryptosystem, assume that Alice and Bob have set up a common key Kab. This key is only known to Alice and Bob.
azamat

Answer:

yes

Explanation:

If it is guranteed the key is only known to Alice and Bob and there is no risk of man in the middle attack or channel spoofing so we can achieve data origin authentication

4 0
3 years ago
What are the five generations of computers?​
inysia [295]

Answer:

First Generation, Second Generation, Third Generation, Fourth Generation, Fifth Generation

Explanation:

First Generation- Vacuum Tubes

Second Generation- Transistors

Third Generation- Integrated Circuits

Fourth Generation- Microprocessors

Fifth Generation- Artificial Intelligence

4 0
3 years ago
Complete the sentence to identify disadvantages of top-down programming design. Choose all that apply. Top-down programming desi
pav-90 [236]

so is it all about codes and codes and codes and codes and codes lol

4 0
3 years ago
To generate a series of first ten counting number of algorithm​
Anettt [7]
Uhh i need points so i don’t fail math.
3 0
3 years ago
Which option can be used to access more settings than are available in the Backstage view?
Bumek [7]

Answer:

orientation settings

Explanation:

so u can now more about whta u doing

6 0
3 years ago
Other questions:
  • An important advantage of using GUI data-entry objects is that you often can control what users enter by limiting their options?
    6·1 answer
  • La inteligencia o unidad lógica de un computador se denomina como??? Software, Hardware CPU o que, ayuda.....
    7·1 answer
  • You can use Facebook's Live Feed tool to broadcast content as you post it, true or false?
    11·1 answer
  • What can happen if you do not follow the directions of medicine or the directions from the doctor? (Give 4 examples)​
    15·1 answer
  • What will be the output of the following code?
    14·1 answer
  • What are 3 similarities and 3 differences between live theatre and film/videos -Drama Class
    13·1 answer
  • Sustainable development is a goal towards which all human societies need to be moving. elaborate the statement in about 120 word
    9·1 answer
  • There are some games that cannot be described by a single--or even two-- genres. Can you think of any that should be invented?​
    6·1 answer
  • What does the word collaborative mean?
    13·2 answers
  • Which of the following is NOT a method for applying the SDLC model?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!