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
Is map ordered c++?
When must you use a pointer rather than a reference?
What is the iunknown interface?
What is function overriding in c++?
Are strings mutable in c++?
What are keywords in c++?
What is the best c++ book for beginners?
What is flush c++?
Explain about Garbage Collector?
Is c++ proprietary?
What is c++ course?
What is a memory leak c++?
What is an iterator class in c++?
Is it possible to provide special behavior for one instance of a template but not for other instances?
What is the difference between a baller and a reference in C++?