I'm trying to write a function of the type void to show the smallest and highest element values of an array that's already been created dynamically. Here's my function for creating the array:
1 2 3 4 5 6 7 8 9 10
int *createArray(int &size)
{
int *array1 = newint[size];
for (int i = 0; i < size; i++)
{
array1[i] = rand() % 20;
}
return array1;
}
How I output the elements:
1 2 3 4 5 6 7
cout << "please enter an array size: ";
cin >> arraysize;
for (int i = 0; i < arraysize; i++)
{
cout << createArray(arraysize) << " ";
}
The other function has to have this prototype:
1 2
void Stats(int *dynArray, int size, int &smallest, int &highest)
{
I know how to find these things, but I have no idea how to go from there because of the smallest and highest parameters. Any feedback is appreciated.
...to arrange them in ascending order, then pull the last element and the first element of the array, to get highest and smallest values respectively, from said array.