Using Void Function to calculated highest, average, and lowest numbers of an array

Hello,
I am having an issue determining why my program won't run. I am thinking there is an issue with the way I have used my void function and pass by reference-- if so, please point this out to me! Also, I have tried to implement bubble sort in order to "calculate" the highest temperature in my array. Average, of course, I will add mathematically. Additionally, I figure I can use an if statement to print all values below 33 degrees. The prompt for my problem is as follows below:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Write a C++ program that does the following:
Creates an array of int called temperatures with 7 elements.
Initialize the array with the following values:
30, 31, 60, 65, 75, 71, 112

Create a void function called calculateTemps which takes in the array of temperatures. It will also take in three variables of type double which are passed by reference and are named highest, avg, and numTempsFreezing. In the body, this function will calculate the three values based on the array
1) The highest temperature
2) The average temperature
3) The number of temperatures at or below 32 (freezing in Fahrenheit)
And these values will be assigned to the corresponding variables.

From main, call the function calculateTemps and display the three values which are the highest and average temperatures and also the number of temperatures below freezing of the provided array as determined by the function.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
#include <iostream>
using namespace std;

void calculateTemps(int& tempsArray, double& highest, double& avg, double& numTempsFreezing) {
	double numTempsFreezing = 0;
	int tempsArray = 0;
	int i, j, n, temp;												// holding temporary variable
	int n = tempsArray.size();
	
	for (i = 1; i < n; i++)
	{
		for (j = 0; j < (n - 1); j++)
		{
			if (tempsArray[j + 1] < tempsArray[j])					// sorts in ascending order
			{
				temp = tempsArray[j];								// switches elements in array
				tempsArray[j] = tempsArray[j + 1];
				tempsArray[j + 1] = temp;
			}
		}
	}

	for (i = 0; i < tempsArray.size; i++)							//for loop gathering number of times a temperature below 32 is found in array
	{
		if (tempsArray[i] < 33)
			numTempsFreezing++;
	}
}

int main() {
	int i;
	int tempsArray[7] = { 30, 31, 60, 65, 75, 71, 112 };			//initializing global array allows for data to used in all functions
	double numTempsFreezing, avg, highest = 0.0;
	calculateTemps(tempsArray[i], tempsArray[0], tempsArray[4], tempsArray[7]);


	cout << "The highest temperature is " << highest << endl << "The average temperature is " << avg << endl
		<< "The number of temperatures that are below freezing is " << numTempsFreezing << endl;

	system("pause");												//pausing output for user viewing
	return 0;
}
I had problems with sizeof inside the function, but this is what I got:
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
#include <iostream>
using namespace std;

void calculateTemps(int tempsArray[], double& highest, double& avg, double& numTempsFreezing) {
	//double numTempsFreezing = 0;
	//int tempsArray = 0;
	int i, j, n, temp;												// holding temporary variable
	//n = sizeof(tempsArray)/sizeof(tempsArray[0]);     tried this but doesn't work
	n = 7;  //works

	for (i = 1; i < n; i++)
	{
		for (j = 0; j < (n - 1); j++)
		{
			if (tempsArray[j + 1] < tempsArray[j])					// sorts in ascending order
			{
				temp = tempsArray[j];								// switches elements in array
				tempsArray[j] = tempsArray[j + 1];
				tempsArray[j + 1] = temp;
			}
		}
	}
	highest = tempsArray[6];

	avg = 0.0;
	for (i = 0; i < n; i++)							//average temperature
	{
		avg = avg + (double)tempsArray[i];
	}
	avg = avg / (double)n;

	numTempsFreezing = 0.0;
	for (i = 0; i < n; i++)							//for loop gathering number of times a temperature below 32 is found in array
	{
		if (tempsArray[i] <= 32)
		{
			numTempsFreezing += 1.0;
		}
	}
}

int main() {
	int i;
	int tempsArray[7] = { 30, 31, 60, 65, 75, 71, 112 };			//initializing global array allows for data to used in all functions
	double numTempsFreezing, avg, highest = 0.0;
	calculateTemps(tempsArray, highest, avg, numTempsFreezing);


	cout << "The highest temperature is " << highest << endl << "The average temperature is " << avg << endl
		<< "The number of temperatures that are below freezing is " << numTempsFreezing << endl;

	system("pause");												//pausing output for user viewing
	return 0;
}
Ah, so an issue with my bubble sort. Thank you SO much for your help! Life saver!
Topic archived. No new replies allowed.