write a program to insert an element into an array
Answer Posted / anupriya garg( sviet)
#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 ? | 15 Yes | 9 No |
Post New Answer View All Answers
In which header file does one find isalpha() a) conio.h b) stdio.h c) ctype.h
How can I disable the "echo" feature?
What are friend classes? What are advantages of using friend classes?
What is class definition in c++ ?
Are php strings immutable?
What is virtual function? Explain with an example
How does the copy constructor differ from the assignment operator (=)?
Is it possible to write a c++ template to check for a function's existence?
What is c++ mutable?
Explain bubble sorting.
Explain overriding.
What is null pointer and void pointer and what is their use?
What's the order in which the objects in an array are destructed?
Can a program run without main?
What is protected inheritance?