C Program to Delete an Element from Array

Arrays are fundamental data structures in programming that allow the storage of multiple elements of the same data type in contiguous memory locations. Manipulation array, such as deleting an element is a common task in programming. In this article we will write a C program to delete an element from array.

Process to Delete Element from Array

To delete an element from an array, we need to shift the remaining elements to fill the gap left by the deleted element. The process involves identifying the index of the element to be deleted, shifting the remaining elements that come after it, and updating the array size.

C Program to Delete an Element from Array

Let’s write a C program to perfrom deletion of an elemnt from an array.

Output

C Program to Delete an Element from Array

  • In the above program, the deletElement function is responsible for deleting the element at the specified index. It performs the deletion by shifting elements to fill the gap and updating the array size.
  • The main function takes user input for the element to delete, and then it checks if the number exists in the array or not. If a number exists in the array then the main function calls the deleteElement function.
  • At the end, the program prints the updated array after deletion.

Happy Coding

See Also

4 thoughts on “C Program to Delete an Element from Array”

Leave a Comment