error message

Hello again,
I created a program that will generate an array from a random number. the program will calculate sum, average, and show the larges and smallest number in the array. after I wrote the code I functionalized it, meaning I created individual functions for the sum, aver, larges and smallest. after this i got the following error message, error C2109: subscript requires array or pointer type. why did this show up after i created different functions. All the errors seem to be at the "lcv" locations. Thank You for your help.
==================================================================================
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include<iostream>
#include <cstdlib>

using namespace std;

const int ARRAY_SIZE = 10;

void GenerateNumber();
void DisplayNumberInArray();
void Sum();
void Average();
void LargestSmallest();

int main()
{

	GenerateNumber();       // Random Number Generator
   
	DisplayNumberInArray(); // Display the Numbers in Array

	Sum();                  // Calculate the Sum

	Average();              // Calculate the Average
	
	LargestSmallest();      // Largest and Smallest


	return 0;
}



void GenerateNumber(int number, int lcv)
{
	int seed;
	cout << "Enter seed for random number generator ==> ";
	cin >> seed;
	srand(seed);
	

	for(lcv = 0; lcv < ARRAY_SIZE; lcv++)
	{
		number[lcv] = rand();
	}

}



void DisplayNumberInArray(int lcv, int number)
{
	cout << "these are the numbers that are in the array " << endl;
	
	for(lcv = 0; lcv < 10; lcv++)
	{
		cout << "                                 " << number[lcv] << endl;
	}
}



void Sum(int lcv, int sum, int number)
{
	cout << "                                _______" << endl << endl;        

	for(lcv = 0; lcv < 10; lcv++)
	{
		sum += number[lcv];
	}
	cout << "                      The sum is " << sum << endl << endl;
}



void Average(int lcv, int sum)
{
	double denom;
	int avg;
	for(lcv = 0; lcv < 10; lcv++)
	{
		double denom = 10.00;
		avg = ( sum / denom );
	}
	cout << "                  The average is " << avg << endl;
}



void LargestSmallest(int lcv, int number)
{
	int max,
		low;
	max = low = number[0]; // Sets values 

	for(lcv = 0; lcv < ARRAY_SIZE; lcv++)
	{
		if(low > number[lcv])   // Check if low is higher, and if it is..
			low = number[lcv];    //  Set low to number[lcv]
		if(max < number[lcv])   //   Check if  max is lower, and if it is.. 
			max = number[lcv]; //    //  Set max to number[lcv]
	}
	cout << "Low = " << low << "\tMax = " << max << endl;
}
You didn't declare the array number anywhere.
@Wisely Done

Thanks for your response. I declared the array on line number 8 but the problem was not corrected. Do you have any other ideas that might solve this problem. Thank you again for your help in this matter.
====================================================================
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include<iostream>
#include <cstdlib>

using namespace std;

const int ARRAY_SIZE = 10;

int number[ARRAY_SIZE];

void GenerateNumber();
void DisplayNumberInArray();
void Sum();
void Average();
void LargestSmallest();

int main()
{
	GenerateNumber();       // Random Number Generator
   
	DisplayNumberInArray(); // Display the Numbers in Array

	Sum();                  // Calculate the Sum

	Average();              // Calculate the Average
	
	LargestSmallest();      // Largest and Smallest

	return 0;
}



void GenerateNumber(int number, int lcv)
{
	int seed;
	cout << "Enter seed for random number generator ==> ";
	cin >> seed;
	srand(seed);
	

	for(lcv = 0; lcv < ARRAY_SIZE; lcv++)
	{
		number[lcv] = rand();
	}

}



void DisplayNumberInArray(int lcv, int number)
{
	cout << "these are the numbers that are in the array " << endl;
	
	for(lcv = 0; lcv < 10; lcv++)
	{
		cout << "                                 " << number[lcv] << endl;
	}
}



void Sum(int lcv, int sum, int number)
{
	cout << "                                _______" << endl << endl;        

	for(lcv = 0; lcv < 10; lcv++)
	{
		sum += number[lcv];
	}
	cout << "                      The sum is " << sum << endl << endl;
}



void Average(int lcv, int sum)
{
	double denom;
	int avg;
	for(lcv = 0; lcv < 10; lcv++)
	{
		double denom = 10.00;
		avg = ( sum / denom );
	}
	cout << "                  The average is " << avg << endl;
}



void LargestSmallest(int lcv, int number)
{
	int max,
		low;
	max = low = number[0]; // Sets values 

	for(lcv = 0; lcv < ARRAY_SIZE; lcv++)
	{
		if(low > number[lcv])   // Check if low is higher, and if it is..
			low = number[lcv];    //  Set low to number[lcv]
		if(max < number[lcv])   //   Check if  max is lower, and if it is.. 
			max = number[lcv]; //    //  Set max to number[lcv]
	}
	cout << "Low = " << low << "\tMax = " << max << endl;
}
In your functions you are hiding the global array number with parameters named number.
All of your functions are asking for variables to be passed, but your prototypes and your function calls don't pass them anything.
Topic archived. No new replies allowed.