sigsegv error.

// program for codechef UNCLE JOHNY

#include <stdio.h>

int main()
{
	int t,pos,i,ujp,j;
	unsigned long int n;
	int arr[n];
	int high=n,low=0,mid;
	scanf("%d",&t);
	while (t)
	{
		scanf ( "%ld",&n);
		low=0;
		high=n;
		mid=(high+low)/2;
		for (i=0; i<n; i++ )
		{
			scanf("%d",&arr[i]);
		}
		scanf ("%d",&ujp); //pos. pf uj in unsorted array
		//uj=arr[ujp-1];
		for (j=0; j<n-1 ; j++)
		{
		for (i=0; i<n-1-j; i++)
		{
			if ( arr[i]>arr[i+1] )
			{
				arr[i]=arr[i]+arr[i+1];
				arr[i+1]=arr[i]-arr[i+1];
				arr[i]=arr[i]-arr[i+1];

			}	
		
		}
		}
			
		while ( low<=high )
		{
			if ( arr[mid]==arr[ujp])
			{
				pos=mid;
				break;
			}
			else if ( arr[mid] > arr[ujp] )
			{
				high=mid-1;
				mid=(low+high)/2;

			}
			else
			{
				low=mid+1;
				mid=(low+high)/2;
		
			}

		}
	
		printf("%d\n",pos+1 );
		t--;
		
	}
}

plzz guys…tell me where is the segmentation fault.

give either your submission page link or write the code properly here …

U r initialising arr with n which is a garbage value. either initialize arr[n] after scanning n or initialize it with arr[101]…

go through the link, it may help you link

here… int arr[n] is creating the problem as garbage value assinged to n by default is more (as it appears) than the alloted contraint, allowed in the program

declare the array with the maximum constraint allowed, I hope that would remove the error.