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 the difference between global variables and local variable
What is object in c++ example?
Will a C compiler always compile C++ code a) Yes b) No c) Only optimized compilers
Can a new be used in place of old mallocq? If yes, why?
what Is DCS ? what i will get benefit when i did?
What are the advantages of using typedef in a program?
What are references in c++?
Explain how we implement exception handling in c++?
What is a type library?
What is rvalue?
What is function overloading c++?
What is token c++?
A company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9 percent of their gross sales for that week. For example, a saleperson who sells $5000 worth of merchandise in a week receives $200 plus 9 percent of $5000, or a total of $650. You have been supplied with a list of items sold by each salesperson. The values of these items are as follows: Item Value A 239.99 B 129.75 C 99.95 D 350.89 Write a program that inputs one salesperson's items sold in a week (how many of item A? of item B? etc.) and calculates and displays that salesperson's earnings for that week.
How long it will take to learn c++?
Explain virtual class and friend class.