Hi.. I am new to Dani web and would like to know the problem in the following code:
#include<iostream.h>
#include<conio.h>
void insertion_sort(int *p);
int main()
{
int a[20],j;
cout<<"\nEnter contents of array:";
for(int k=0;k<20;k++)
{
cin>>a[k];
}
insertion_sort(a);
return 0;
}
void insertion_sort(int *p)
{
int h,key;
for(int i=2;i<20;i++) //Insert into the sorted array p[1:i-1]
{
key= p[i];
h=i-1;
while(h>0&&p[h]>p[i])
{
p[h+1]=p[h];
h--;
p[h+1]=key;
}
}
cout<<"\nSorted array:";
for(int m=0;m<20;m++)
{
cout<<p[m];
cout<<endl;
}
}
This runs fine.. but produces no output..