/Wrtite a program to sort elements of given array having ‘n’ numbers of elements, using Insertion sort

#include
#include
main()
{
int a[100];
int i,n,temp,j,k;
clrscr();
cout<>n;
cout<<"enter array :" ;
for(i=0;i>a[i];
}
for(i=1;i=0 && a[j]>temp)
{
a[j+1]=a[j];
j–;
}
a[j+1]=temp;
}

for(i=0;i<n;i++)
{
cout<<a[i];
}
getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *