SIGSEGV ERROR IN PRIME1

#include<stdio.h>
#include<math.h>

int main(void)
{
unsigned long int n, m;
int a[100000], b[100000], i, j, t;

scanf("%d", &t);
while(t--)
{
    scanf("%d%d", &m, &n);
    for(i=2; i<(n-m); i++)
    {
        a[i]=1;
    }
    for(i=2;i<sqrt(n-m);i++)
    {
        if(a[i])
        {
            for(j=i;i*j<(n-m);j++)
            {
                a[i*j]=0;
            }
        }
    }
    j =1;
    for(i=m; i<=n;i++)
    {
        if(a[i])
        {
            b[j++] = i;
        }
    }
    for(i=1; i<j; i++)
    {
        printf("%ld\n", b[i]);
    }
}
return 0;

}

could anyone please help me to find why is it giving sigsegv error??

You declared the array as a[100000]. What if the value of n-m exceeds 100000? You cannot find a place in the array for that number.May be that’s why it is giving SIGSEGV ERROR.Take care of that.

All the best!!!