#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,temp,arr[10],n;
clrscr();
printf("\nEnter size of ayyar");
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&arr[i]);
}
for (i = 1; i < n; i++)
{
int tmp = arr[i];
int j;
for (j = i; j > 0; j--)
{
if (arr[j - 1] < tmp)
break;
arr[j] = arr[j - 1];
}
arr[j] = tmp;
}
printf("\nSorted array is \n");
for(i=0;i<n;i++)
{
printf("%d\n",arr[i]);
}
getch();
}
No comments:
Post a Comment