I was using bubble sort even though i know time complexity is high but while submitting i though i would get TLE but i got runtime error SIGSEGV can tell me why?
here is code
#include <stdio.h>
int main(void) {
int t,i,c,n ;
scanf("%d",&t) ;
while(t--)
{
scanf("%d",&n) ;
int arr[i] ;
for(i=0;i<n;i++)
scanf("%d",&arr[i]) ;
int c=1 ;
while(c!=0)
{
c=0 ;
for(i=0;i<n-1;i++)
{
if(arr[i]>arr[i+1])
{
c=1 ;
break ;
}
}
if(c==1)
for(i=0;i<n-1;i++)
{
if(arr[i]>arr[i+1])
{
int j=arr[i+1] ;
arr[i+1]=arr[i] ;
arr[i]=j ;
}
}
}
printf("%d\n",arr[0]+arr[1]) ;
}
return 0;
}