0

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.

Here is what I have come up with so far....

#include <iostream>
using namespace std;

int main()
{
    int sum = 0;
    int average = 0;
    int array[10] = {1,2,3,4,5,6,7,8,9,10};
    for (int i = 0; i < 10; ++i)
        sum+=array[i];
    average = sum/10;
    cout<<"Average:"<<average;
}
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by zortec
0

You have not written any of the functions which is the main part of your assignment. The code that you provided is most basic. You have a total of three functions. Try to see if you can come up with any code for those on your own.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.