I’m stuck on a C Programming question and need an explanation.
#include <stdio.h>_x000D_
#define N 10_x000D_
_x000D_
int search(int a[], int n, int value) {_x000D_
int i;_x000D_
for (i = 0 ;i < n ; i++ ) {_x000D_
if (a[i] == value)_x000D_
return i;_x000D_
}_x000D_
return -1;_x000D_
}_x000D_
_x000D_
int main() {_x000D_
int i;_x000D_
int length, element, value, array[N];_x000D_
_x000D_
printf("Enter the length of the array: n");_x000D_
scanf("%d", &length);_x000D_
_x000D_
printf("Enter the elements of the array: n");_x000D_
for (i = 0; i < length; i++) {_x000D_
scanf("%d", &array[i]);_x000D_
}_x000D_
_x000D_
printf("Enter the value for searching: n");_x000D_
scanf("%d", &element);_x000D_
_x000D_
value = search(array, length, element);_x000D_
_x000D_
if (value == -1)_x000D_
printf("%d", -1);_x000D_
else_x000D_
printf("%d", value);_x000D_
_x000D_
return 0;_x000D_
}
_x000D_
Modify the program so that it deletes all instances of the value from the array. As part of the solution, write and call the function delete() with the following prototype. n is the size of the array. The function returns the new size of the array after deletion (The array after deletion will be the same size as before but the actual elements are the elements from index 0 to new_size-1). In writing function delete(), you may include calls to function search(). The main function takes input, calls the delete() function, and displays the output.
int delete(int a[], int n, int value);
Example input/output #1:
Enter the length of the array: 6
Enter the elements of the array: 4 3 1 0 3 9
Enter the value for deleting: 3
Output array: 4 1 0 9