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
Explain operator overloading.
What is the fastest c++ compiler?
List the advantages of inheritance.
What is the difference between a template and a macro?
What are associate containers?
What is c++ hash?
Is eclipse good for c++?
Why should you learn c++?
How a new operator differs from the operator new?
What is the difference between a definition and a declaration?
What are c++ manipulators?
What is the cout in c++?
Is there structure in c++?
What is the best it certification?
What parameter does the constructor to an ofstream object take?