Segmentation fault (core dumped) in quick sort algorithm
<p>Below is my code for Quick sort i C. I am getting Segmentation fault Core Dumped.
I tried hard to resolve the issue but found nothing.</p>

<pre><code>#include&lt;stdio.h&gt;

int divide(int a[], int p, int q) {
    int mid, i, lastsmall, temp;

    mid = (p + q)/2;
    temp = a[mid];
    a[mid] = a[p];
    a[p] = temp;
    int pivot = a[p];
    lastsmall = p;

    for (i = p + 1; i &lt;= q; i++) {
        if (a[p] &gt; pivot)
            continue;
        else {
             lastsmall++;
             temp = a[i];
             a[i] = lastsmall;
             lastsmall = a[i];
        }
    }
    return lastsmall;
}

void quick(int a[], int p, int q) {
    int pivot;
    if (p &lt; q) {
        pivot = divide(a, p, q);
        quick(a, p, pivot);
        quick(a, pivot + 1, q);
    }
}

int main() {
    int ar[10], i;

    printf("Enter the list\n");
    for (i = 0; i &lt; 10;i++)
        scanf("%d", &amp;ar[i]);
    quick(ar, 0, 9);
    for (i = 0; i &lt; 10; i++)
        printf("%d ", ar[i]);
    return 0;
}
</code></pre>