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

Define upcasting.

982


What are protected members in c++?

1073


Write bites in Turbo c++ Header ("Include") Files.

1202


Suppose that data is an array of 1000 integers. Write a single function call that will sort the 100 elements data [222] through data [321].

1398


What is time_t c++?

1060


What is abstraction with real time example?

1101


Why c++ is better than c language?

953


What are the advantages of using typedef in a program?

1100


an operation between an integer and real always yeilds a) integer result b) real result c) float result

1105


How const int *ourpointer differs from int const *ourpointer?

1066


How would you obtain segment and offset addresses from a far address of a memory location?

1023


What do you mean by persistent and non persistent objects?

1353


Write a program using shift_half( ) function to shift the elements of first half array to second half and vice versa.

1264


To which numbering system can the binary number 1101100100111100 be easily converted to?

996


What methods can be overridden in java?

1193