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( sviet)

#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 ?    15 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Should I learn c or c++ first?

1127


Explain the volatile and mutable keywords.

1072


What are the rules for naming an identifier?

1064


Are c and c++ similar?

1056


Explain what is class definition in c++ ?

1127


Explain selection sorting. Also write an example.

1051


Explain how overloading takes place in c++?

1047


Why is it necessary to use a reference in the argument to the copy constructor?

1115


What are the advantages of inheritance in c++?

1106


Is c++ vector a linked list?

999


What is a constant reference?

1077


Why main function is special in c++?

1127


What is cin clear () in c++?

1228


How does the copy constructor differ from the assignment operator (=)?

1150


What is meant by entry controlled loop? What all C++ loops are exit controlled?

1091