Assigning values to an Array

So I understand how to display Arrays that have already been initialized. What im trying to do is make an array and then have the user enter 5 numbers that gets stored in the array.

this is what I have so far.
1
2
3
4
5
6
7
8
9
10
  void getScores(double testScores[], int size)
{
	cout << "Enter 5 Test Score: " << endl;

	for (int i = 0; i < size; i++)
	{
        //I dont know what goes in here
	}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>

using namespace std;

int main()
{
    double testScores[5];

    // enter data
    cout << "Enter 5 Test Score: " << endl;
    for (int i = 0; i < 5; i++)
    {
        cin >> testScores[i];
    }

    // print result
    for (int i = 0; i < 5; i++)
    {
        cout << endl << testScores[i] << endl;
    }

    return 0;
}

Last edited on
Topic archived. No new replies allowed.