sorting of array elements using pointer in c language

void main()
{
int i,j,t;
int arr[5]={11,0,3,9,-8};
for(i=1;i<5 data-blogger-escaped-div="" data-blogger-escaped-i="">
{
t=*(arr+i);
j=i-1;
while((t<*(j+arr))&&(j>=0))
{
*(arr+j+1)=j[arr];
j=j-1;
}
1[arr+j]=t;
}
clrscr();
for(i=0;i<5 data-blogger-escaped-div="" data-blogger-escaped-i="">
printf("%d ",arr[i]);
getch();
}

Output: -8 0 3 9 11

No comments: