Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

write a program to insert an element into an array

Answer Posted / harini

#include<iostream>
#include<conio.h>
main()
{
int a[5],b,n,e,i,j;
std::cout<<"enter the no of elements:";
std::cin>>n;
std::cout<<"enter the array elements:";
for(i=0;i<n;i++)
{
std::cin>>a[i];
}
std::cout<<"enter the position of insertion:";
std::cin>>b;
std::cout<<"enter the element to be inserted:";
std::cin>>e;
for(j=n;j>b;j--)
{
a[j]=a[j-1];
}
a[j]=e;
std::cout<<"the new array elements are:\n";
for(j=0;j<=n;j++)
{
std::cout<<a[j]<<"\n";
}
getch();
}

Is This Answer Correct ?    5 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How would you find out if a linked-list is a cycle or not?

1004


What is a friend function in c++?

1627


Explain the difference between overloading and overriding?

1136


Can a constructor be private?

1068


What is stl containers in c++?

1047


Explain the problem with overriding functions

1147


What is a .lib file in c++?

991


What is the full form of ios?

1060


Who calls main function?

1108


Write a program to interchange 2 variables without using the third one.

1050


What is the difference between passing by reference and passing a reference?

1076


What do you know about near, far and huge pointer?

1136


What are disadvantages of pointers?

1034


If you want to share several functions or variables in several files maitaining the consistency how would you share it?

984


What are the differences between the function prototype and the function defi-nition?

1094