#include<iostream.h>
#include<conio.h>
void main()
{
int s,n,i,a[50],p;
clrscr();
cout<<"Enter the number of elements of array : ";
cin>>n;
cout<<"Enter the elements : ";
for(i=0;i<n;i++)
cin>>a[i];
cout<<"Enter the new element and its position : ";
cin>>s>>p;
for(i=n;i>=p;i--)
a[i]=a[i-1];
a[p]=s;
cout<<"The array after inserting new element is : ";
for(i=0;i<n+1;i++)
cout<<a[i]<<" ";
getch();
}
To know about array click here
#include<conio.h>
void main()
{
int s,n,i,a[50],p;
clrscr();
cout<<"Enter the number of elements of array : ";
cin>>n;
cout<<"Enter the elements : ";
for(i=0;i<n;i++)
cin>>a[i];
cout<<"Enter the new element and its position : ";
cin>>s>>p;
for(i=n;i>=p;i--)
a[i]=a[i-1];
a[p]=s;
cout<<"The array after inserting new element is : ";
for(i=0;i<n+1;i++)
cout<<a[i]<<" ";
getch();
}
To know about array click here
Your programs are so interesting.
ReplyDelete