Insert operation is to insert one or more data elements into an array. Based on the requirement, new element can be added at the beginning, end or any given index of array.
Here, we see a practical implementation of insertion operation, where we add data at the end of the array.
Let LA is a Linear Array (unordered) with N elements and K is a positive integer such that K<=N.
//Write a program to perform Insertion operation.
#include <stdio.h>
void main()
{
int LA[] = {2,4,6,8,9};
int item = 11, k = 3, n = 5;
int i = 0, j = n;
printf("The original array elements are:\n");
for(i = 0; i<n; i++)
{
printf("LA[%d] = %d \n", i, LA[i]);
}
n = n + 1;
while( j >= k)
{
LA[j+1] = LA[j];
j = j - 1;
}
LA[k] = item;
printf("The array elements after insertion:\n");
for(i = 0; i<n; i++)
{
printf("LA[%d] = %d \n", i, LA[i]);
}
}
sir data structure ki book pdf me download kyo nahi ho rahi hai please send book my email sksaroj464@gmail.com
I want to delete an element from beginning and at end of array Plz post the program for that
Ask Question