Write a recursive function that replaces all the occurrences of an integer I1 in an array
of integers by some another integer I2.


Difficulty level
This exercise is mostly suitable for students
void replace_rec(int arr[],int start,int end,int E1,int E2)
{
	if (start<=end)
	{
		if (arr[start]==E1)
			arr[start]=E2;
		replace_rec(arr,start+1,end,E1,E2);
	}
}

void replace(int arr[],int N,int E1,int E2)
{
	replace_rec(arr,0,N-1,E1,E2);
}

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Maximum sum in sliding window