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
How can the Internet help our country to be a leader in technology?
BigorU [14]

Answer:

it can help in the aspect of making technologies to be fastly operated with fast internet connection there by it top among all other countries

4 0
2 years ago
Bytes are arrangements of
tigry1 [53]
The answer is B. Eight bits
7 0
2 years ago
Which of the following was the most significant impact the NEA had on the performing arts industry? W
Sedaia [141]

Answer:

The NEA’s focus on building new performing arts centers led to an increased production of arts.

5 0
2 years ago
What type of object is a GUI widget the user can click to select an option, and allows for any number of these objects to be sel
andre [41]

Answer:

Checkbox

Explanation:

I remember this question.

4 0
3 years ago
What is the cheapest type of printer to buy and run?
myrzilka [38]
It depends solely on how much you will use it. For example, laser printers are more suitable for offices, schools, and environments, where the printer is used almost constantly. If it's used a lot, you're probably looking at a laser printer, since the cartridges have a slightly higher price, but a much higher yield. If you can't afford a laser printer, and you're only going to use it at home, you're probably looking at an inkjet. If you need to print off something for school, ask your teacher, or someone that works at your school. Some secondary/high schools might allow you to use their printers at a lower price
7 0
3 years ago
Read 2 more answers
Other questions:
  • A misfire code is a type _______ diagnostic trouble code (DTC).
    5·1 answer
  • How can i repair computer processor?
    12·1 answer
  • What default length is used for the ospf dead interval?
    14·1 answer
  • If you delete a sent message on gmail does the person still get it
    14·1 answer
  • Digital printing is not suitable for printing what
    11·1 answer
  • Compare and contrast inertial confinement with thermonuclear reactors.
    7·1 answer
  • 23. What is the value of 3 - (4 + 2 *3)/(8-2) + 7 * 2+4
    7·1 answer
  • In the program below, which two variables have the same scope?
    9·2 answers
  • Point giveaway and brainliest
    7·2 answers
  • What is the output of the following code segment?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!