insertion sort - c programwrite a program in c to


Insertion sort - C program:

Write a program in c to define a insertion sort.

void main()

 {

  clrscr();

  int a[100],ch,n;

  cout<<"enter the limit for the array : ";

  cin>>n;

  for (int i=0;i

                {

                cout<<"enter element "<

                cin>>a[i];

                }

                clrscr();

                cout<<"1. insertion sorting "<

                isort(a,n);

                 }

 }

void isort(int a[100],int n)

 {

                 clrscr();

                int te,i,j;

                for(i=1; i

                  {

                   te=a[i];

                                j=i-1;

                                 while (te=0)

                                   {

                                   a[j+1]=a[j];

                                   j=j-1;

                                   }

                                  a[j+1]=te;

                  }

                   cout<<" sorted arrays by insertion "<<"\n\n";

                   for(i=0; i

                   cout<

                   getch();

 }

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: insertion sort - c programwrite a program in c to
Reference No:- TGS0174879

Expected delivery within 24 Hours