DS

Update Operation

Update operation refers to updating an existing element from the array at a given index.

Example

 Consider LA is a linear array with N elements and K is a positive integer such that K<=N.

//Write a program to perform updation operation.
#include <stdio.h>
void main()
{
   int LA[] = {1,3,5,7,8};
   int k = 3, n = 5, item = 11;
   int i, j;

   printf("The original array elements are:\n");

   for(i = 0; i<n; i++)
   {
      printf("LA[%d] = %d \n", i, LA[i]);
   }

   LA[k-1] = item;

   printf("The array elements after updation:\n");

   for(i = 0; i<n; i++)
   {
      printf("LA[%d] = %d \n", i, LA[i]);
   }
}

Output:

Command Prompt
The original array elements are:
LA[0]=2
LA[1]=4
LA[2]=6
LA[3]=8
LA[4]=9
The array elements after updation:
LA[0]=2
LA[1]=4
LA[2]=11
LA[3]=8
LA[4]=9



Subscribe us on Youtube

Share This Page on

Question


Emelyn | 20-Jun-2018 08:17:19 pm

Hi! may i know how to make the flowchart to this update operation?Thanx


Ask Question