I wrote this code to find the mode of an array of values.

```
double mode (double * array, int numItems)
{
int j, i, maxRepeats = 0;
double mode;
for(i = 0; i < numItems; i++)
{
j = 1;
while(array[i] == array[i+j])
{
++j;
}
if(j > maxRepeats)
{
mode = array[i];
maxRepeats = j;
}
}
return mode;
}
```

Is there any way to do this without using nested loops?

Thanks.