Functions not running properly, error: expected expression

My program is supposed to be an array which size is given by the user and then filled with random numbers, sorted, and find the median. I have written 3 functions, none of which are running properly. They all get the same error, expected expression. Not really sure why they are getting this error and any advice is very much appreciated.

#include <iostream>
#include <ctime>

using namespace std;

/**
Fills the array with random values
@param dynamic_array The array, not yet filled or sorted
@param SIZE Size of the array
@param max_numb Highest number allowed to exist in the array
@param min_numb Lowest number allowed to exist in the array
*/
void fill_array(unsigned dynamic_array[], size_t SIZE,
int min_numb, int max_numb);

/**
Sorts the filled array
@param dynamic_array The array is filled, but not yet sorted
@param SIZE Size of the array
*/
void sort_array(unsigned dynamic_array[],size_t SIZE);

/**
Finds the median of the array
@param dynamic_array The filled and sorted array
@param SIZE Size of the array
@return median The median of the array
*/
double find_median(unsigned dynamic_array[], size_t SIZE);

int main()
{
size_t SIZE;
cout << "Enter the number of values: ";
cin >> SIZE;

int min_numb;
cout << "Enter the minimum value: ";
cin >> min_numb;

int max_numb;
cout << "Enter the maximum value: ";
cin >> max_numb;

int* dynamic_array = new int[SIZE];

fill_array(dynamic_array[], SIZE, min_numb, max_numb); //The functions getting errors
sort_array(dynamic_array[], SIZE);

double median = find_median(dynamic_array[], SIZE);

cout << "The values in order: [" << dynamic_array[SIZE] << "]" << endl;
cout << "The smallest value in the array is " << dynamic_array[0] << endl;
cout << "The largest value in the array is " << dynamic_array[SIZE - 1]
<< endl;
cout << "The median value is " << median << endl;

delete[] dynamic_array;

return 0;
}

void fill_array(unsigned dynamic_array[], size_t SIZE,
int min_numb, int max_numb)
{
srand(time(NULL));

for (unsigned position = 0; position < SIZE; position++)
{
int fill_value;
fill_value = rand() % (max_numb - min_numb + 1) + min_numb;
dynamic_array[position] = fill_value;
}
}

void sort_array(unsigned dynamic_array[], size_t SIZE)
{
int pos_min;
int temp;

for (int index = 0; index < SIZE - 1; index++)
{
pos_min = index;

for (int index_2 = index + 1; index_2 < SIZE; index_2++)
{
if (dynamic_array[index_2] < dynamic_array[pos_min])
{
pos_min = index_2;
}
}
if (pos_min != index)
{
temp = dynamic_array[index];
dynamic_array[index] = dynamic_array[pos_min];
dynamic_array[pos_min] = temp;
}
}
}

double find_median(unsigned dynamic_array[], size_t SIZE)
{
int middle;
double median;

middle = SIZE / 2;

if (SIZE % 2)
{
median = (dynamic_array[middle] + dynamic_array[middle + 1]) / 2.0;
}
else
{
median = dynamic_array[middle];
}
return median;
}
In future please use code tags and if you have compiler errors/warnings post them exactly as they appear in your development environment.

When calling a function where you're trying to pass an array you don't need the [].

You also need to make sure you're comparing the same types of variables, be careful about comparing things like unsigned int and int. You should compare an unsigned int to an unsigned int, a size_t to a size_t, etc.

Topic archived. No new replies allowed.