Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that uses an array to find the Average of 10 double values. Allo

ID: 3812597 • Letter: W

Question

Write a program that uses an array to find the Average of 10 double values. Allow the use to enter values for the 10 double numbers. A for loop will facilitate the user input of the 10 random values. Then use a different for loop to iterate through the array summing the total for all 10 double values. Update summing method to incorpate a recrusive method to sum the numbers in the array. Create 1 method to handle user input Create 1 method to sum and output average of all numbers in array Create 1 method to output the list of numbers. Output the list of numbers input by user. Output the average of all the numbers.

Explanation / Answer

#include <iostream>
#include <vector>

using namespace std;


void printArray(int theArray[], int sizeOfarray);
int average(int numbers[], int size);
int getnum();
int main()
{

int size=10; //Array size
int array[size]; //Declaring array
getnum();
printArray(array, 10);

cout << "The average is: " << average(array,10) << endl;

return 0;
}
//Method to take user input
int getnum()
{
int size=10; //Array size
int array[size]; //Declaring array

int sum=0;
for(int i=0;i<size;i++) //Loop which inputs arrays data and

{
cout<<"Enter element number "<<i+1<<endl;
cin>>array[i];
}
}
//Method to print list of numbers
void printArray(int theArray[], int sizeOfarray)
{
cout<<"List of Numbers in array:"<<endl;
for (int x = 0; x < sizeOfarray; x++)
{
  
cout << theArray[x] << endl;

}
}
//Method to calculate average and sum
int average(int numbers[], int size)
{
int sum = 0;
int arrayAverage;
for (int x = 0; x < size; x++)
{
sum += numbers[x];
arrayAverage = sum / size;
}
return (arrayAverage);
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote