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

#include<stdio.h>
#include<conio.h>
void insert(int b[],int n,int pos,int item);
void main()
{
int a[6]={10,20,30,40,50},p,c,item;
printf("enter item and position for insertion");
scanf("%d%d",&item,&p);
printf("array before insertion");
for(c=0;c<=4;c++)
{
printf("%d\n",a[c]);
}
insert(a,6,p,item);
printf("array after insertion");
for(c=0;c<=5;c++)
{
printf("%d\n",a[c]);
}
getch();
}
void(int b[],int n,int pos,int item)
{
int c;
c=n-1;
while(c>pos)
{
b[c]=b[c-1];
c--;
}
b[c]=item;
}

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are shallow and deep copies?

1120


To which numbering system can the binary number 1101100100111100 be easily converted to?

1069


What do nonglobal variables default to a) auto b) register c) static

1159


How many different levels of pointers are there?

1220


Describe linked list using C++ with an example.

1091


write a programme to get a character and thier ASCII value

3054


What is a dll entry point?

1014


What is an object in c++?

1274


Differentiate between a pointer and a reference with respect to c++.

1255


Write a program using shift_half( ) function to shift the elements of first half array to second half and vice versa.

1339


Which function should be used to free the memory allocated by calloc()?

1029


What is implicit pointer in c++?

1096


What new()is different from malloc()?

1121


What is a down cast?

1122


What are stacks? Give an example where they are useful.

1066