Write A Program To Insert A Number In Array
#include <stdio.h>
#include <conio.h>
int main()
{
int array[100], p, c, n, value;
printf("Enter size of array: ");
scanf("%d", &n);
printf("Enter %d elements: ", n);
for (c = 0; c < n; c++)
scanf("%d", &array[c]);
printf("Enter the location where you wish to insert an element: ");
scanf("%d", &p);
printf("Enter the value to insert: ");
scanf("%d", &value);
for (c = n; c >= p; c--)
array[c+1] = array[c];
array[p-1] = value;
printf("Resul of array is: ");
for (c = 0; c < n; c++)
printf("%d ", array[c]);
getch();
}
#include <conio.h>
int main()
{
int array[100], p, c, n, value;
printf("Enter size of array: ");
scanf("%d", &n);
printf("Enter %d elements: ", n);
for (c = 0; c < n; c++)
scanf("%d", &array[c]);
printf("Enter the location where you wish to insert an element: ");
scanf("%d", &p);
printf("Enter the value to insert: ");
scanf("%d", &value);
for (c = n; c >= p; c--)
array[c+1] = array[c];
array[p-1] = value;
printf("Resul of array is: ");
for (c = 0; c < n; c++)
printf("%d ", array[c]);
getch();
}