Insertion in array..







#include<iostream.h>
#include<conio.h>
void main()
{
cout<<"Enter the values of array";
int pos,a[5],i,val;
for(i=0;i<5;i++)
{
cin>>a[i];
}
for(i=0;i<5;i++)
{
cout<<a[i];
}
//after insertion
cout<<"Enter the position";
cin>>pos;
cout<<"Enter the value";
cin>>val;
int j=4;
while (a[j]>a[pos])
{
a[j]=a[j-1];
j--;
}a[pos]=val;
for(int k=0;k<5;k++)
{
cout<<a[k];
}
getch();
}
Posted by lol ik

Comments

Popular Posts