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 / abhishek

This is just perfect, i compiled it right now!!

#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],i,n,ent,ins;
clrscr();
printf(" enter how many nos u wanna putin");
scanf("%d",&n);
if(n<1||n>20)
{
printf(" invalid input");
return;
}
printf(" Enter the elements into the array one by one");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}

printf("the elements in the array");
for(i=0;i<n;i++)
{
printf("%d",a[i]);
}

printf(" Which address field will occupy the new element");
scanf("%d",&ins);--ins;

printf(" enter the elemnt u wanna put in");
scanf("%d",&ent);
for(i=n;i>=ins;i--)
{


a[i+1]=a[i];
}

a[ins]=ent; n++;


printf(" the new array after insertion of nu elemnt");

for(i=0;i<n;i++)
{
printf("%d",a[i]);
}
getch();
}

Is This Answer Correct ?    4 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Define linked lists with the help of an example.

977


How do you sort a sort function in c++ to sort in descending order?

939


What is the disadvantage of using a macro?

1049


What are libraries in c++?

1014


Assume an array of structure is in order by studentID field of the record, where student IDs go from 101 to 500. Write the most efficient pseudocode algorithm you can to find the record with a specific studentID if every single student ID from 101 to 500 is used and the array has 400 elements. Write the most efficient pseudocode algorithm you can to find a record with a studentID near the end of the IDs, say in the range from 450 to 500, if not every single student ID in the range of 101 to 500 is used and the array size is only 300

2169


Write a Program to find the largest of 4 no using macros.

1028


What are signs of manipulation?

1006


What is general form of pure virtual function? Explain?

938


What number of digits that can be accuratly stored in a float (based on the IEEE Standard 754)? a) 6 b) 38 c) An unlimited number

1199


Who created c++?

1003


Is c++ double?

976


What is a v-table?

1097


Does std endl flush?

972


What is #include math h in c++?

1023


Describe linked list using C++ with an example.

1021