write a program to insert an element into an array
Answer Posted / vijesh kumar
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a[20],n,x,y,i,pos=0;
a[0]=1;
a[1]=3;
a[2]=4;
a[3]=5;
a[4]=6;
x=2;
y=1;
for(i=5+1;i>y;--i){
a[i]=a[i-1];
}
a[y]=x;
cout<<"\nAfter the inserting : ";
for(i=0;i<6;i++){
cout<<a[i]<<" ";
}
getch();
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is the basic structure of a c++ program?
How to access a variable of the structure?
What is abstract keyword in c++?
What gives the current position of the put pointer?
Why is c++ not purely object oriented?
What is ifstream c++?
What are the advantage of using register variables?
What is virtual destructor? What is its use?
Write a program to interchange 2 variables without using the third one.
How delete [] is different from delete?
What is abstraction with real time example?
Define a pdb file.
Explain the problem with overriding functions
Can we declare a base-class destructor as virtual?
Describe about storage allocation and scope of global, extern, static, local and register variables?