Remove Element from an Array

For Complete YouTube Video: Click Here

In this class, we will understand Remove Element from an Array.

The entire course of C Programming with more than 110+ videos of content or playlist has already been published.

We have covered all the concepts of C Programming in a very detailed way.

C Programming Complete Playlist on YouTube: Click Here

All the concepts discussed in this course are the models frequently asked in Campus Placements Questions, either in multiple-choice questions or as programming questions.

This entire course will help a Computer Science Engineering Student or a student in any other stream crack the campus placements drives held by Service-based Software or IT companies like TCS, Infosys, CTS, Wipro, Accenture, etc.

Remove Element from an Array

Question

In this program an element from the array at a given index and move all the remaining elements one step ahead.

Test Cases:

Example1:

Input: 9, 3, [1, 2, 3, 4, 5, 6, 7, 8, 9]

Output: 1 2 3 5 6 7 8 9

Example2:

Input: 6, 6, [1, 2, 3, 4, 5, 6]

Output: 1 2 3 4 5 6

Given Code:

void removeElement(int size, int indexValue, int *inputList)
{
	int i, j;
	if(indexValue<size) 
	{
		for(i= indexValue;i<size-1;i++) 
		{
			inputList[i] = inputList[i++];
		}
		for(i=0;i<size-1;i++)
			printf("%d ",inputList[i]);
	}
	else {
		for(i=0;i<size; i++)
			printf("%d ",inputList[i]);
	}
}

In the above code, there are some mistakes in the problem.

The explanation of the question is provided in the above YouTube link.