write a program to insert an element into an array

Answer Posted / vinay kumar

#include<iostream.h>
#include<conio.h>
void main()
{ clrscr();
int a[50],i,n,j,p;
cout<<"Enter the size of the array : ";
cin>>n;
cout<<"Enter the elements of the array :\n";
for(i=1;i<=n;i++)
{
cin>>a[i];
}
cout<<"Enter the new element to store : ";
cin>>j;
cout<<"Enter the postion : ";
cin>>p;
a[n+1]=a[p];
a[p]=j;
cout<<"The New series is : \n";
for(i=1;i<=n+1;i++)
{ cout<<a[i]<<"\t";
}
getch();
}

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a lambda function c++?

547


How can you specify a class in C++?

791


Explain stack unwinding.

628


What is a literal in c++?

561


What character terminates all character array strings a) b) . c) END

667






Describe the advantage of an external iterator.

610


what are the iterator and generic algorithms.

1477


How do you declare A pointer to function which receives an int pointer and returns a float pointer

672


How many types of scopes are there in c++?

570


What is an iterator?

684


What is the copy-and-swap idiom?

602


What is token c++?

574


Why struct is used in c++?

617


Is c++ platform dependent?

627


True or false, if you keep incrementing a variable, it will become negative a) True b) False c) It depends

1853