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

What are advantages of c++?

959


what are the types of Member Functions?

1085


What is the difference between while and do while loop? Explain with examples.

1058


Can we use clrscr in c++?

1026


What is scope operator in c++?

1041


How the keyword struct is different from the keyword class in c++?

990


write a c++ program to create class student having datamember name,Roll_no,age,and branch intilcization all the member using constructor print the all the details on the screen.

2650


What is struct c++?

951


Is there any function that can skip certain number of characters present in the input stream?

1016


True or false, if you keep incrementing a variable, it will become negative a) True b) False c) It depends

2315


Do you know the problem with overriding functions?

1039


Why was c++ made?

1042


What is the difference between an external iterator and an internal iterator? Describe an advantage of the external iterator.

1001


Explain the uses oof nested class?

1096


Is c++ primer good for beginners?

991