Below is the code I am trying to run, I keep getting the error Segmentation fault. Added Compare. In the below program I need to consider an array of 5000000 or less(this is n) numbers and implement quicksort on those numbers.
int compare (const void * a, const void * b)
{
  const double *da = (const double *) a;
  const double *db = (const double *) b;
  return (*da > *db) - (*da < *db);
  }
int main(){
int n = rand()% 5000000;
double arr[n];
for (int i=0; i<n; i++)
{
    arr[i] = (double)rand();
}
qsort(arr,n, sizeof(double), compare);
 for (int  i=0;i<n;i++){
     cout<<arr[i]<<"\n";
 }
     return 0;
 }
 
     
     
     
    