Why am I getting a run time error(SIGSEGV) for the following code? : <p>This is the solution of the Prime Generator problem on SPOJ(Sphere online judge), I have checked and no array is out of bound, and still it is showing run time error.</p>

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

int main(){
    int n;
    int i,j,a,b;
    scanf("%d", &amp;n);

    while(n){
        scanf("%d %d", &amp;a, &amp;b);
        int arr[b];

        // Filling the array
        for(i=2;i&lt;=b;i++){
            arr[i-2]=i;
        }

        int p,c;
        for(p=0;p&lt;b-1;p++){
            if(arr[p]){
                if(arr[p]&gt;=a){
                    printf("\n%d", arr[p]); 
                }
                for(c=p+arr[p];c&lt;b-2;c+= arr[p]){
                    arr[c]=0;
                }
            }
        }
        n--;    
    }
</code></pre>
