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

#include <stdio.h>

int main()
{
int array[100], position, c, n, value;

printf("Enter number of elements in array\n");
scanf("%d", &n);

printf("Enter %d elements\n", n);

for (c = 0; c < n; c++)
scanf("%d", &array[c]);

printf("Enter the location where you wish to insert an
element\n");
scanf("%d", &position);

printf("Enter the value to insert\n");
scanf("%d", &value);

for (c = n - 1; c >= position - 1; c--)
array[c+1] = array[c];

array[position-1] = value;

printf("Resultant array is\n");

for (c = 0; c <= n; c++)
printf("%d\n", array[c]);

return 0;
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is std :: string immutable?

1097


What does floor mean in c++?

1112


Can malloc be used in c++?

1130


What is a pointer with example?

1332


Explain register storage specifier.

1051


What is null pointer and void pointer and what is their use?

1149


Briefly describe a B+ tree. What is bulk loading in it?

1397


What are the two types of comments?

1048


Can the creation of operator** is allowed to perform the to-the-power-of operations?

1054


Difference between a copy constructor and an assignment operator.

1047


What happens when you make call 'delete this;'?

1152


What is the type of 'this' pointer?

1060


What is using namespace std in c++?

1206


How come you find out if a linked-list is a cycle or not?

1083


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

1380