write a program to insert an element into an array
Answer Posted / simi
void insert(int*,int pos,int num);
void main()
{
int a[10],num,pos,i;
cout<<"Enter number which is to be inserted";
cin>>num;
cout<<"Enter position where no. is to be inserted";
cin>>pos;
insert(a,1,78);
insert(a,2,3);
getch();
}
void insert(int *a,int pos,int num)
{
int i;
for(i=9;i>=pos;i--)
{
a[i]=a[i-1];
}
a[i]=num;
}
| Is This Answer Correct ? | 2 Yes | 3 No |
Post New Answer View All Answers
Explain the pure virtual functions?
How do I exit turbo c++?
When is the destructor called?
What is constructor c++?
What is nested class in c++?
What is a list c++?
What does int * mean in c++?
What does new do in c++?
Can we make any program in c++ without using any header file and what is the shortest program in c++.
How is objective c different from c++?
Why c++ is faster than java?
What is ios :: in in c++?
What is ios class in c++?
which of the following is not an secondary constant a) array b) real c) union
Can comments be longer than one line?