Breaking News
recent

WAP to insert a new element in an array

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a[10],i,n,x,y;
cout<<"enter the no. of element ";
cin>>n;
cout<<"Enter the elements :"<<endl;
  for(i=0;i<n;i++)
   {
       cin>>a[i];
         }
            for(i=0;i<n;i++)
              cout<<"a["<<i<<"]"<<"="<<a[i]<<endl;
             cout<<"Enter the place where you want to insert: ";
            cin>>x;
            cout<<"Enter the element to be entered: ";
            cin>>y;
for(i=0;i<x;i++)
cout<<a[i]<<endl;
cout<<y<<endl;
              for(i=x;i<n;i++)
              cout<<a[i]<<endl;

getch();
}

Output:



Unknown

Unknown

No comments:

Post a Comment

Powered by Blogger.