Insertion Based on value

#include<iostream.h>
#include<conio.h>


void insert(int a[],int n,int d)
{
    int i,pos=0;
    if(d>=a[n-1])
        a[n]=d;
    else
        {
        while(a[pos]<=d)
            pos++;
        for(i=n-1;i>=pos-1;i--)
            {
            a[i+1]=a[i];
            }
        a[pos]=d;
        }
}
void main()
{
clrscr();
int a[50],i,n,d;
cout<<"Enter the number of elements ";
cin>>n;
cout<<"Enter the elements";
for(i=0;i<n;i++)
    {
    cin>>a[i];
    }
cout<<"Enter the element to be inserted";
cin>>d;
insert(a,n,d);
cout<<"After Insertion";
for(i=0;i<=n;i++)
    {
    cout<<a[i]<<",";
    }
getch();
}