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 dev c++ a good compiler?

904


What can c++ be used for?

1046


When are exception objects created?

1028


How the delete operator differs from the delete[]operator?

1057


Can circle be called an ellipse?

1032


Which bit wise operator is suitable for checking whether a particular bit is on or off?

976


What is Destructor in C++?

1147


How do you invoke a base member function from a derived class in which you have not overridden that function?

1077


What is public, protected, private in c++?

1108


Which is the best c++ compiler for beginners?

1029


What are abstract data types in c++?

941


What is private, public and protected inheritance?

1045


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

1036


How will you call C functions from C ++ and vice-versa?

1093


If a header file is included twice by mistake in the program, will it give any error?

997