I am trying to store the sum 1/k^2 in an array using this code:

```
int main()
{ 
int i,n, e;
double terms[n];
double x, y;

printf(" Introduce n\n");
scanf("%d", &n);

y=1;
i=0;

while(e<n)
  {
   x=1/((y)*(y));
   printf("x is %.16lf\n",x);
   terms[i]=x;
   printf("terms is %.16lf\n", terms[i]);
   y++;
   i++;
   e++;
  }
}

```

And I get the "segmentation fault" error. Why is this happening? How can I avoid it?

I am programming in C