Hello. I am trying to write a program that averages judges scores that the user inputs. The user will be able to enter the number of scores as well. I have to use two different functions. One that gets the number of scores, gets the scores, and then stores it in an array. The other function calculates the average of the scores. I am having trouble with the array part. It is giving me an error and saying "expression must have a constant value". I'm new to programming so mind my ignorance. Thanks for any help.
#include<iostream>
using namespace std;
int getScore();
double calcAverage(int sumScores, int numScores);
int main()
{
getScore();
double calcAverage(int, int);
getScore();
system("pause");
}
int getScore()
{
int numScores;
cout << "How many scores would you like to enter?" << endl;
cin >> numScores;
int judgeScores[numScores];
int x;
for (x = 0; x < numScores; x++)
{
cout << "Enter your score" << endl;
cin >> judgeScores[x];
}
int numScores; // Must be constant and specify the size for static array (i.e. const int numScores{10})
cout << "How many scores would you like to enter?" << endl;
cin >> numScores;
int judgeScores[numScores];
For static arrays, you must specify the number of elements in the array.