Write a program that will ask the user for 10 numbers, store them in an array, print the array, and print the average of the numbers entered.

You should:

All steps should be pseudo-coded before actually going to the computer, and you will be required to submit the pseudo-code of your project (in a doc or txt file) as part of your submission.

Write a function that prompts the user to enter 10 numbers, accepting double format, and return an array containing those numbers.
Write a function to output the elements of the array in a nice format.
Write a function which accepts the array as input and returns the average of the numbers in the array.
Write a main program to effectively tie these functions together and solve the problem.
Define at least two sets of test data and the expected results when the program will run using these sets as input. Include these test cases in your doc or txt file.

Where is the code you have written to solve that problem???

#include <iostream>
using namespace std;

void getArray(double arValues[10])
{
cout << "Please enter 10 numbers :" << endl;
for (int i = 0; i < 10; i++)
cin >> arValues;
}

void printArray(double arValues[10])
{
cout << "Numbers in array :" << endl;
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 5; j++)
cout << arValues << " ";
cout << endl;
}
}

double getAverage(double arValues[10])
{
double dsum = 0;
for (int i = 0; i < 10; i++)
dsum += arValues;
return dsum / 10;
}

int main()
{
// array
double arValues[10];

// get 10 numbers from user
getArray(arValues);

// print array
printArray(arValues);

// calculate average and print it
cout << "Average of Array : " << getAverage(arValues);

return 0;

}

This article has been dead for over six months. Start a new discussion instead.