guys please help me to find the sigsegv runtime error in this c code

c
code

#1

#include<stdio.h>
int main()
{int arr[100],i,n,t,j;
scanf("%d",&n);
for(i=0;i<n;i++)
{scanf("%d",&arr*);
}
for(i=0;i<n;i++)
{for(j=i+1;j<n;j++)
{if(arr*>arr[j])
{t=arr*;
arr*=arr[j];
arr[j]=t;
}}}
for(i=0;i<n;i++)
printf("%d
",arr*);
return(0);
}


#2

why int arr[100] ?

I can see you are solving Turbo sort.


#3

i have also done it by taking 1 million elements but then its show time limit exeeded…


#4

yes it is turbo sort,and i am using arr[100] so that the user can give input 100 elements …i have run this code on turbo c and its runs perfectly in it!!! so why am i getting runtime error in this??


#5

i am using arr[100] so that the user can give input 100 elements

…and in problem statement it’s written, that there can be up to one million elements…


#6

because your sorting algorithm is quite slow. Read about Quicksort and Mergesort


#7

Even that might give a TLE. Try counting sort.