write a program to insert an element into an array
Answer Posted / ajay
21.cout<<"Enter another element: ";
22.cin>>num;
23.cout<<"Enter position number: ";
24.cin>>pos;
25.cout<<endl;
26.--pos;
27.for(i=size;i>=pos;i--)
28.a[i+1]=a[i];
29.a[pos]=num;
30.size++;
31.cout<<"New Array: "<<endl;
32.for(i=0;i<size;i++)
33.cout<<"Element at position "<<i+1<<" is "<<a[i]<<endl;
Is This Answer Correct ? | 1 Yes | 2 No |
Post New Answer View All Answers
What is the type of 'this' pointer?
What's the order in which the objects in an array are destructed?
Why do we need templates?
What is a stack c++?
What are the various situations where a copy constructor is invoked?
Write bites in Turbo c++ Header ("Include") Files.
What is the full name of logo?
write a function signature with various number of parameters.
Is c++ an oop?
Can we make any program in c++ without using any header file and what is the shortest program in c++.
What is data type in c++?
Why do we need constructors in c++?
Can I have a reference as a data member of a class? If yes, then how do I initialise it?
What is the difference between *p++ and (*p)++ ?
What is function overloading in C++?