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


Please Help Members By Posting Answers For Below Questions

What is a storage class used in c++?

618


Can we use struct in c++?

595


Can you please explain the difference between static and dynamic binding of functions?

572


How a new element can be added or pushed in a stack?

583


What is the full form of stl in c++?

680






What is c++ array?

554


What is the purpose of templates in c++?

565


Explain about templates of C++.

678


Does there exist any other function which can be used to convert an integer or a float to a string?

653


Define pure virtual function?

564


What language does google use?

590


What is a pdb file?

542


What is protected inheritance?

602


What is null pointer and void pointer?

627


What is ios flag in c++?

688