Hello,

I have this function

Code:
`void smallAverage(int *array, float *average, int *numSmallerThanAverage );`
which returns in the parameters, average and numSmallerThanAvergae, the corresponding result. average is the average value of all the elements of the array. numSmallerThanAverage is the number of elements in the array which are smaller than the average.
I need to redefine the above function such that it utilizes pass by reference to return the results, i.e., the average and the number of elements smaller than the average.

Now, I have the code for the pass by pointer function, even though I'm not really sure if its alright and its perfect and I would really appreciate it if someone would take a look at it for me...
for the pass by reference function, I dont know how to do it, but I was guessing that it would be the same as my pass by pointer function except that I would change every
Code:
`*`
with
Code:
`&`
everywhere they are found in the function such as:

Code:
`void smallAverage(int &array, float &average, int &numSmallerThanAverage );`
I dont know if I'm wrong or not and I really need help please..oh by the way I dont know if that would be helpful, but these two functions need to be tested in a main routine and print the results. The main function must accept the size of the array as a command line parameter. And the array should be initialized with random numbers.

Here is my code:

Code:
```#include <iostream>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

int main(int argc, char* argv[])
{
int size;
int* myArray = NULL;

if (argc >= 2) size = atoi (argv[1]);
else {
cout << "Enter array size in command line: ";
return -1;
}
myArray = new int[size];
srand(time(NULL));
for(int i = 0; i < size; i++){
myArray[i] = rand();
}
float* average;
int* numSmallerThanAverage;
smallAverage(myArray, average, int* numSmallerThanAverage);
delete[] myArray;
return 0;
}

/****************************************function # 1**********************************************************/
void smallAverage(int *myArray, float *average, int *numSmallerThanAverage)
{
int size;
int sum = 0;
for(int i = 0; i < size; ++i){
sum += myArray[i];
}
*average = (float)sum/(float)size;

*numSmallerThanAverage = 0;
for(int i = 0; i < size; i++)
cout << myArray[i] << " ";
for(int i = 0; i < size; i++) //check until condition i=size
{
if(*average > myArray[i])
(*numSmallerThanAverage)++;
}
cout << "\nSearching..." << endl;
//display the result...
cout << "The number of elements smaller than the average value is = " << *numSmallerThanAverage << endl;
}```