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 pure virtual function?
what is data encapsulation in C++?
What is the history of c++?
Of the numbers 12 23 9 28 which would be at the top of a properly implemented maxheap a) 28 b) 9 c) Any of them could be
How do we balance an AVL Tree in C++?
What is a set in c++?
Am studying basic c++ programming, have been given the following assignment. Design a linear program to calculate the maximum stress a material can withstand given a force and a diameter of a circle. To find the required area pi should be defined. Have most of the program sorted out but am at a loss as to how to show the calculations required. Can anyone help?
What is cin clear () in c++?
What is a singleton c++?
What does new in c++ do?
What is a v-table?
What is linked list in c++?
What is constant in c++ with example?
What is the size of integer variable?
Which compiler does turbo c++ use?