I am writing a C program and getting message 'Segmentation fault (core dumped) ' : <p>The program is to find out the smallest positive number which is not in the array. When I try to test my code, it shows the message 'Segmentation fault (core dumped)'. I am new to program c, are there anyone can help?</p>

<pre><code>#include &lt;stdio.h&gt;
int n = 5;
int i, j, k, x = 1, temp;
int array[] = {5, 1, 4, 5, 7};

void swap(){
    temp = array[i];
    array[i] = array[j];
    array[j] = temp;
}

void sorting(){
    for (i = 0; i &lt; n; i++){
        for (j = i + 1; j &lt; n; j++){
            if (array[i] &gt; array[j]){
                swap();
            }
        }
    }
}

void checking(){
    sorting();
    for (k = 0; k &lt; n; k++){
        if (x != array[k]){
            printf('%d',array[k]);
            break;
        }
            else x++;
    }
}

int main()
{
    checking();
}
</code></pre>
