You are on page 1of 1

#include <stdio.

h>

int main(void) {
int i,j,k,temp;
int a[6]={5,4,10,1,6,2};
for(k=1;k<6;k++)
{
temp=a[k];
j=k-1;
while(j>=0&&temp<=a[j])
{
a[j+1]=a[j];
j=j-1;
}
a[j+1]=temp;
}
printf("\n sorted elements are:");
for(i=0;i<6;i++)
{
printf("%d\t",a[i]);
}

return 0;
}

You might also like