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
Is c++ platform dependent?
What is c++ similar to?
Does c++ have arraylist?
What is a string example?
What are the advantages of c++?
Mention the ways in which parameterized can be invoked. Give an example of each.
Will rust take over c++?
What do you mean by “this” pointer?
What is pointer to member?
Write a program using merge () function to combine the elements of array x[ ] and y[ ] into array z[ ].
What are static variables?
Explain all the C++ concepts using examples.
Explain about vectors in c ++?
Explain what are mutator methods in c++?
What is the use of main function in c++?