Vs does not print output

This code is not printing the output

int merge(int *a, int s, int e)
{
int mid = (s+e)/2;
int i = s;
int j = (mid+1);
int k = s;

int temp[100000];

int cnt = 0;
while (i<=mid && j<=e)
{
    if(a[i] <= a[j]){
        temp[k] = a[i];
        k++;
        i++;
    }
    else{
        temp[k+1] = a[j++];
        cnt+=(mid-i+1);
    }
}

//fill the array if some elements are left in one of the arrays.
while (i<=mid){
    temp[k++] = a[j++];
}
while(j<=e){
    temp[k++] = a[j++];
}

// Copy all elements back to array a
for(int i = s; i<= e; i++){
    a[i] = temp[i];
}

return cnt;

}

int inversionCount(int *arr, int s, int e)
{

//base case
if(s>=e){
    return 0;
}

int mid = (s+e)/2;
int x = inversionCount(arr,s,mid);
int y = inversionCount(arr,mid+1,e);
int z = merge(arr,s,e);
int sum = x+y+z;
return sum;

}

int main()
{
int n = 6;
int arr[] = {1,5,2,6,3,0};

cout << inversionCount(arr,0,n-1) << endl;

return 0;

}

@jinisha25jain565503,
r u getting /bin/run.sh: line 4: 18 Segmentation fault (core dumped) ./exe?

@jinisha25jain565503,
//fill the array if some elements are left in one of the arrays.
while (i<=mid){
temp[k++] = a[j++];
}
here instead of i++ u wrote j++

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.