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
Define the operators that can be used with a pointer.
List different attributes in C++?
Can member functions be private?
Explain bubble sorting.
What is helper in c++?
Which is better turbo c++ or dev c++?
Is c++ proprietary?
What is static class data?
What are c++ tokens?
How is computer programming useful in real life?
How much do c++ programmers make?
In which header file does one find isalpha() a) conio.h b) stdio.h c) ctype.h
What is unary operator? List out the different operators involved in the unary operator.
How do you establish an is-a relationship?
Do class declarations end with a semicolon? Do class method definitions?