DSA 7.99 - Delete function in an array

PHOTO EMBED

Tue Apr 11 2023 15:03:07 GMT+0000 (Coordinated Universal Time)

Saved by @saakshi #c++

int delete(struct Array *arr, int index)
{
  int x=0;
  int i;
  
  if (index >= 0 && index < arr->length)
    {
      x = arr-> A[index];
      for(i = index; i<arr->length-1; i++)
        arr ->length--;
      return x;
    }
  return 0;
}

int main()
{
  struct Array arr= {{2,3,4,5,6},10,5};

  printf("%d\n", Delete(&arr,4));

  return 0;
}
content_copyCOPY