VOOZH about

URL: https://www.geeksforgeeks.org/c/c-program-to-remove-all-occurrences-of-an-element-in-an-array/

⇱ C Program to Remove All Occurrences of an Element in an Array - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C Program to Remove All Occurrences of an Element in an Array

Last Updated : 2 Aug, 2022

To remove all the occurrences of an element in an array, we will use the following 2 approaches: 

  1. Using Methods
  2. Without using methods or With Conditional Statement

We will keep the same input in all the mentioned approaches and get an output accordingly.

Input:

array = {1, 2, 1, 3, 1} 
value = 1 

Output:

array = {2, 3} 

Explanation: The given value 1 is to be removed from the array of elements. So, the resultant array is {2, 3} after removing the 1 from an array.

Method 1: Using functions

Approach A:


Output
2 3 

Approach B:


Output
2 3 

Method 2: Without using functions

Approach A:


Output
2 3 

Approach B:


Output
2 3 
Comment
Article Tags: