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 binary search.
Define macro.
Can we make any program in c++ without using any header file and what is the shortest program in c++.
What do you mean by static variables?
What are the new features that iso/ansi c++ has added to original c++ specifications?
write a c++ program to create class student having datamember name,Roll_no,age,and branch intilcization all the member using constructor print the all the details on the screen.
Are vectors faster than arrays?
I was a c++ code and was asked to find out the bug in that. The bug was that he declared an object locally in a function and tried to return the pointer to that object. Since the object is local to the function, it no more exists after returning from the function. The pointer, therefore, is invalid outside.
what are Access specifiers in C++ class? What are the types?
write a program that withdrawals,deposits,balance check,shows mini statement. (using functions,pointers and arrays)
Is there finally in c++?
What are the advantages of using const reference arguments in a function?
What is an object in c++?
What are the differences between the function prototype and the function defi-nition?
How do you decide which integer type to use?