Deletion in an array involves removing an element from a specific position in the array. Here's an example implementation of deleting an element from an array in C:
```
#include <stdio.h>
void delete_element(int arr[], int n, int pos) {
// Shift elements to fill deleted element's position
for (int i = pos; i < n-1; i++) {
arr[i] = arr[i+1];
}
}
int main() {
int arr[10] = {1, 3, 5, 7, 9};
int n = 5; // number of elements in array
int pos = 2; // position to delete element
delete_element(arr, n, pos);
n--; // decrement number of elements in array
// Print array after deletion
for (int i = 0; i < n; i++) {
printf("%d ", arr[i]);
}
return 0;
}
```
In this implementation, the `delete_element()` function takes an array, its length, and the position to delete as input. The function shifts all elements after the delete position to the left to fill the gap left by the deleted element. The `main()` function initializes an array and then deletes an element from it at position 2. Finally, it prints the array after deletion.
Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.
We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc