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 #include sstream?
What is an adaptor class or wrapper class in c++?
What are vectors used for in c++?
What is searching?
what is the use of void main() in C++ language?
What happens when you make call 'delete this;'?
Assume studentNames and studentIDs are two parallel arrays of size N that hold student data. Write a pseudocode algorithm that sorts studentIDs array in ascending ID number order such that the two arrays remain parallel.
How can I learn c++ easily?
How can I improve my c++ skills?
Can member functions be private?
What is heap sort in c++?
List the issue that the auto_ptr object handles?
Explain about Garbage Collector?
What does obj stand for?
What is #include cstdlib in c++?