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
What is == in programming?
What is function prototyping?
Can we make any program in c++ without using any header file and what is the shortest program in c++.
What are the classes in c++?
What is data binding in c++?
What is the use of class in c++?
What is the meaning of c++?
Can a built-in function be recursive?
What are maps in c++?
Describe about storage allocation and scope of global, extern, static, local and register variables?
which one is equivalent to multiplying by 2:Left shifting a number by 1 or Left shifting an unsigned int or char by 1?
What is lambda expression c++?
What is a lambda function c++?
What are protected members in c++?
What is c++ runtime?