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

Is it possible for the objects to read and write themselves?

1061


What are function prototypes?

1191


What is istream and ostream in c++?

1057


Can I run c program in turbo c++?

971


Explain the virtual inheritance in c++.

1007


Write a program to show polymorphism in C++?

1082


Distinguish between new and malloc and delete and free().

958


What are virtual functions in c++?

1123


What is the most useful programming language?

997


Can char be a number c++?

992


How do you remove an element from a set in c++?

1032


What do the keywords volatile and mean mutable?

1007


How much maximum can you allocate in a single call to malloc()?

1062


What do you mean by ‘void’ return type?

1003


Why is c++ not purely object oriented?

965