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 ios flag in c++?
What is the v-ptr?
What is size_type?
What is c strings syntax?
Write about the access privileges in c++ and also mention about its default access level?
How can I learn c++ easily?
What is array give example?
What is recursion?
How is new() different from malloc()?
What are pointers, when declared, intialized to a) NULL b) Newly allocated memory c) Nothing. Its random
Explain overriding.
What doescout<<(0==0) print out a) 0 b) 1 c) Compiler error: Lvalue required
What are the differences between new and malloc?
What are special characters c++?
What is a literal in c++?