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 a storage class used in c++?
Can we use struct in c++?
Can you please explain the difference between static and dynamic binding of functions?
How a new element can be added or pushed in a stack?
What is the full form of stl in c++?
What is c++ array?
What is the purpose of templates in c++?
Explain about templates of C++.
Does there exist any other function which can be used to convert an integer or a float to a string?
Define pure virtual function?
What language does google use?
What is a pdb file?
What is protected inheritance?
What is null pointer and void pointer?
What is ios flag in c++?