delete from array

I’m stuck on a C Programming question and need an explanation.

#include <stdio.h>
#define N 10

int search(int a[], int n, int value) {
    int i;
    for (i = 0 ;i < n ; i++ ) {
        if (a[i] == value)
            return i;
    }
    return -1;
}

int main() {
    int i;
    int length, element, value, array[N];

    printf("Enter the length of the array: n");
    scanf("%d", &length);

    printf("Enter the elements of the array: n");
    for (i = 0; i < length; i++) {
    scanf("%d", &array[i]);
    }

    printf("Enter the value for searching: n");
    scanf("%d", &element);

    value = search(array, length, element);

    if (value == -1)
        printf("%d", -1);
    else
        printf("%d", value);

    return 0;
}

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

Read more
OUR GIFT TO YOU
15% OFF your first order
Use a coupon FIRST15 and enjoy expert help with any task at the most affordable price.
Claim my 15% OFF Order in Chat

Good News ! We now help with PROCTORED EXAM. Chat with a support agent for more information