#include<iostream.h>
#include<conio.h>
void main()
{
                int a[10],i,location,element,n;
                clrscr();
                cout<<"Enter The Number of Elements : ";
                cin>>n;
                for(i=0;i<n;i++)
                                {
                                cout<<"Enter The Value A["<<i<<"] = ";
                                cin>>a[i];
                                }
                cout<<"\nEnter The Location At Which Element will be inserted : ";
                cin>>location;
                cout<<"Enter The New Element To be Inserted : ";
                cin>>element;
                for(i=n;i>=location;i--)
                                {
                                a[i]=a[i-1];
                                }
                a[i]=element;
                n++;
                cout<<"\nAfter Inserted Of New Element : \n\n";
                for(i=0;i<n;i++)
                                {
                                cout<<"A["<<i<<"] = "<<a[i]<<endl;
                                }
                getch();
}

92.PNG

Advertisements