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

What is else syntax in c++?

1140


What is the function to call to turn an ascii string into a long?

1012


Explain the scope of resolution operator.

1062


Is c# written in c++?

938


What is the sequence of destruction of local objects?

939


What is stream and its types in c++?

1009


What is the basic concept of c++?

971


How do you import payscale data from non SAP to SAP?is it through LSMW or any other way is there?

3605


Write some differences between an external iterator and an internal iterator? Describe the advantage of an external iterator.

1031


Write a corrected statement in c++ so that the statement will work properly. if (4 < x < 11) y=2*x;

1977


Why c++ is so important?

1036


What are proxy objects in c++?

1137


Can you sort a set c++?

953


Which is the best c++ compiler for beginners?

1041


How do you differentiate between overloading the prefix and postfix increments?

1052