why my code is showing SIGSEGV error in problem ALASKA of spoj and what can I do to correct it?

The code(C gcc 4.3.2) is----

#include<stdio.h>

int main()

{int n,i,k,j,temp,a[1425],flag=1;

while(1)

{

scanf("%d",&n);

if(n==0)

return 0;

for(i=0;i<n;i++)

{scanf("%d",a[i]);

}

for(k=0;k<n-1;k++)

{for(j=0;j<n-1-i;j++)

{if(a[j]>a[j+1])

{temp=a[j];

a[j]=a[j+1];

a[j+1]=temp;

}

}

}

flag=1;

for(i=1;i<n;i++)

{if(a[i]-a[i-1]>200)

{flag=0;}

}

if((1422-a[n-1])*2>200)

flag=0;

if(flag==0)

printf(“IMPOSSIBLE\n”);

else

printf(“POSSIBLE\n”);

}

}

the reason for SIGSEGV is that you are not using &(ampersand) in scanf .

correct it …

Post the update code and if possible give an ideone link for the same.

Thanks a lot …but I am still gettin Wrong Answer…I am new to coding so sometimes i do silly mistakes…can u please tell me the cause of my wrong answer?

a typo i suppose , while sorting, loop of j should be from 0 to n-1-k not n-1-i

AC after making this change

check your j loop

Thanks a lot…

Thanks a lot…