write a program to insert an element into an array
Answer Posted / anupriya garg
#include<iostream.h>
void main()
{
int a[60],n,item,pos;
cout<<"enter the no. of elements in array";
cin>>n;
cout<<"enter the elements";
for(int i=0;i<=n;i++)
{
cin>>a[i];
}
for(int i=0;i<=n;i++)
{
cout<<a[i];
}
cout<<"enter the item to be inserted";
cin>>item;
cout<<"enter the position";
cin>>pos;
for(int i=n;i>=pos;i--)
{
a[i+1]=a[i];
}
a[pos]=item;
n=n+1;
cout<<"the modified array is ;\n\n";
for(int i=1;i<=n;i++)
cout<<a[i];
}
| Is This Answer Correct ? | 17 Yes | 4 No |
Post New Answer View All Answers
Write an algorithm that determines whether or not an almost complete binary tree is a heap.
Explain the static storage classes in c++.
What is the use of pointer in c++ with example?
How do you add an element to a set in c++?
What are features of c++?
Why is polymorphism useful?
What is a type library?
What are the types of pointer?
Which is not an ANSII C++ function a) sin() b) tmpnam() c) kbhit()
What is copy constructor? Can we make copy constructor private in c++?
Tell me what are static member functions?
What is constant in c++ with example?
Why c++ is better than c language?
Is c++ the most powerful language?
Using a smart pointer can we iterate through a container?