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


Please Help Members By Posting Answers For Below Questions

What is the type of 'this' pointer?

605


What's the order in which the objects in an array are destructed?

862


Why do we need templates?

542


What is a stack c++?

578


What are the various situations where a copy constructor is invoked?

610






Write bites in Turbo c++ Header ("Include") Files.

690


What is the full name of logo?

596


write a function signature with various number of parameters.

569


Is c++ an oop?

594


Can we make any program in c++ without using any header file and what is the shortest program in c++.

617


What is data type in c++?

561


Why do we need constructors in c++?

621


Can I have a reference as a data member of a class? If yes, then how do I initialise it?

709


What is the difference between *p++ and (*p)++ ?

783


What is function overloading in C++?

737