write a program to insert an element into an array
Answer Posted / awais jamil
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int j,x[6]={1,2,3,4,5};
int i,pos;
cout<<"please enter for position"<<endl;
cin>>pos;
cout<<"enter for number"<<endl;
cin>>j;
for(i=4;i>=pos;i--)
{
x[i]=x[i-1];
}
x[pos]=j;
for(i=0;i<6;i++)
cout<<x[i]<<" ";
getch();
}
| Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
What is the function of I/O library in C++ ?
Why do we use constructor?
What is an inclusion guard?
What is flush programming?
Is it possible for a member function to use delete this?
Show the declaration for a static function pointer.
What are static variables?
What is a singleton class c++?
What are the operators in c++?
What is the most useful programming language?
Is multimap sorted c++?
Explain how would you handle a situation where you cannot call the destructor of a local explicitly?
Explain how a pointer to function can be declared in C++?
Who made c++?
How the delete operator differs from the delete[]operator?