i am getting runtime error in the following code(sigsev).plzz help me out.

#include<stdio.h>
main()
{int a,b ,c,d,e,f,n,i,q;int head,tail;
scanf("%d",&a);
for(b=0;b<a;b++)
{scanf("%d",&c);
for(d=0;d<c;d++)
{scanf("%d%d%d",&i,&n,&q);
int array[n];
for(e=0;e<n;e++)
array[e]=i;

for(e=0;e<n;e++)
{for(f=0;f<=e;f++)
array[f]+=1;
}
head=0;tail=0;

for(e=0;e<n;e++)
if(array[e]%2==0)
tail++;
else
head++;
if(q==1)
printf("%d",head);
else
printf("%d",tail);
}
}
return 0;
}

it will depend on the value of n. If you scan the value of n very high say in range of 10^6 it will give runtime error. Also, you should initialize the array outside for loop, it is taking too much memory for your code.If you really want to increase the size of your array declare your array[100000000] global i,e, outside main function and keep size of array less 100000001.