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 happens if a pointer is deleted twice?
Explain stack & heap objects?
What will the line of code below print out and why?
What is a vector c++?
Is linux written in c or c++?
How is objective c different from c++?
Difference between overloaded functions and overridden functions
How long will it take to learn programming?
Which is the best c++ software?
What is searching? Explain linear and binary search.
How does c++ structure differ from c++ class?
What is an accessor in c++?
How do you differentiate between overloading the prefix and postfix increments?
Is swift faster than c++?
What is low level language in simple words?