PRIME1 - Getting a a SIGSEGV on submitting , working fine locally

#include<stdio.h>

void printprime(int a,int b)
{
 int k,i;
 int arr[b+1];
 for(i=2;i<=b;i++)
  arr[i]=1;

 for(i=2;i<=b;i++)
 {
  if(arr[i]!=0)
  {
   for(k=2*i;k<=b;k+=i)
   {
    arr[k]=0;
   }
  }
 }
for(i=2;i<=b;i++)
 if(arr[i]!=0 && i>=a)
  printf("%d\n",i);
}

int main()
{
 int test,a,b;
 scanf("%d",&test);
 while(test--)
 {
  scanf("%d %d",&a,&b);
  printprime(a,b);
  if(test!=0)
   printf("\n");
 }
 return 0;
}

One of the cause of SIGSEGV error is allocating too much memory. In your solution, maximum value of a and b can be upto 10^9. You cannot declare an array of size 10^9. This is the cause of SIGSEGV.

The maximum heap memory that can be allocated to an array is 10^7 whereas in your code in the extreme case you cannot allocate an array of 10^9 integers. That causes a SIGSEV error / runtime error.