can anybody please help me find out which part of the code mentioned below
is probably causing a segmentation error.I would be grateful enough.
#include <stdio.h>
int main()
{
int t,i;
long int n,sum,j,sindex,eindex,arr[10000001],currentsum;
scanf("%d",&t);
for(i=0;i<t;i++)
{
scanf("%ld %ld",&n,&sum);
sindex=1;
eindex=0;
currentsum=0;
for(j=1;j<=n;j++)
{
scanf("%ld",&arr[j]);
currentsum+=arr[j];
eindex++;
while(currentsum>sum)
{
currentsum-=arr[sindex];
sindex++;
}
if(currentsum==sum)
printf("%ld %ld",sindex,eindex);
}if(sindex==n+1)
printf("-1");
}
return 0;
}
