Array passed to a function

Hello, I am trying to write a program that uses an array that's passed to a function. I am really bad with Functions and Arrays.
Can I get some helps or tips on improving my code. I understand the general idea
but I get stuck early on when I get this error code.
"error C2057: expected constant expression " Any help please. This is my code so far.
-uses an array to hold 5 numbers
-menu of choices is displayed
-depending on the choice, a math operation is performed on all
the values in the array.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include<iostream>
#include<cmath>
using namespace std;

const double SIZE = 5;
void getValues(double numbers[],double SIZE);
void showMenu();
void getChoice(char & choice );
void doTheMath(double numbers[],double SIZE,double & root, double & sum, double & average, char & choice);

int main()
{
	
	double numbers[SIZE];

	char choice;
	double root;
	double sum;
	double average;
	
	getValues(numbers,SIZE);
	showMenu();
	getChoice(choice);
	doTheMath(numbers,SIZE,root,sum,average,choice);


}
void getValues(double numbers[],double SIZE)
{
	cout << "Enter 5 numbers:\n";
	
	for(int i = 0; i<SIZE; i++)
	{
		cout << i + 1 <<".";
		cin >> numbers[i];
		
	}
	system("cls");
		
}
void showMenu()
{
	cout << "A.Display the Square Root of each number.\n"
		 << "B.Display the Sum of all numbers.\n"
		 << "C.Display the average of all numbers.\n\n\n";
		

}
void getChoice(char & choice )
{
	cout << "Enter your choice: ";
	cin >> choice;
	system("cls");
	
}
void doTheMath(double numbers[],double SIZE,double & root, double & sum, double & average, char & choice)
{
	switch (choice)
	{
	case 'A':	cout << "The square roots are.\n\n";
				for (int i = 0; i<SIZE; i++)
				{
					 root = sqrt(double(numbers[i]));
					 cout << "#" << i+1 << ":  " << root << endl;
				}        
	case 'a':
		break;
	
	case 'B':	cout << "The sum of all numbers is\n\n";
				for (int i = 0; i<SIZE; i++)
				{
					sum += numbers[i];
				}
	case 'b':
		break;

	case 'C':   cout << "The average of the numbers is\n\n\";
				average = double (sum) / double(SIZE);
	case 'c':
		break;
	
	default: cout << "Invalid entry";
		break;
	}
} 
I noticed that you are trying to make a function input values into an array that is in main. The compiler does not like the way it is done because it's trying to access a variable that is within another function, which is bad. There are at least two ways that I can think of to fix this:

1. Declare your array global. (Not a good decision mostly)

2. Use pointers. (Good decision)

Sadly, I'm not really much of an expert when it comes to pointers, but with this, at least someone else that knows more about pointers could possibly help you out. Sorry for not being too much of a help.
Oh okay. Thank you. I will look into that. So what i did for now was bring
const double SIZE = 5; down inside of main and changed
double numbers[SIZE]; to double numbers[5];
It compiled but I am not sure if that was technically correct to do.
Topic archived. No new replies allowed.