Replace Min and Max Placements Practice 9

For Complete YouTube Video: Click Here

In this class, we will understand Replace Min and Max Placements Practice 9.

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.

Replace Min and Max Placements Practice 9

Question

The program given below is used to Replace all odd elements with minimum elements and all even elements with the maximum element.

Given Code:

void replaceMinMax(int size, int *arr)
{
	int i;
	if(size>0)
	{
		int max=arr.0;
		int min=arr.0;
		for(i=0;i<size; i++)
		{
			if(max<arr[i])
			{
				max=arr[i];
			}
			else if(min>arr[i])
			{
				min=arr[i];
			}
		}
		for(i=0;i<size; i++)
		{
			if(arr[i]%2==0)
				arr[i]=max;
			else
				arr[i]=min;
		}
	}
}

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

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