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 / anupriya garg

#include<iostream.h>
void main()
{
int a[60],n,item,pos;
cout<<"enter the no. of elements in array";
cin>>n;
cout<<"enter the elements";
for(int i=0;i<=n;i++)
{
cin>>a[i];
}
for(int i=0;i<=n;i++)
{
cout<<a[i];
}
cout<<"enter the item to be inserted";
cin>>item;
cout<<"enter the position";
cin>>pos;
for(int i=n;i>=pos;i--)
{
a[i+1]=a[i];
}
a[pos]=item;
n=n+1;
cout<<"the modified array is ;\n\n";
for(int i=1;i<=n;i++)
cout<<a[i];
}

Is This Answer Correct ?    17 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What type of question are asked in GE code writing test based on c++ data structures and pointers?

3939


How can a struct in c++ differs from a struct in c?

1002


What is c++ virtual inheritance?

1092


Which compiler does turbo c++ use?

1031


What is the array and initializing arrays in c++?

997


What is istream and ostream in c++?

1081


Can we inherit constructor in c++?

1045


What size is allocated to the union variable?

1023


What is the difference between new() and malloc()?

1982


What are special characters c++?

994


What is the equivalent of Pascal's Real a) unsigned int b) float c) char

985


What are the characteristics of friend functions?

983


What gives the current position of the put pointer?

958


Is c++ a software?

1160


What data structure is fastest, on average, for retrieving data: a) Binary Tree b) Hash Table c) Stack

1042