Regarding failing testcase

why is my code not passing all the test cases


make modifications in my code and explain the error in my code.

@D19APPPP0016 here is the correct code https://ide.codingblocks.com/s/237956

Bro I asked you to correct my code and help me identify my error.
I already had two solutions in my hand for this problem but was not able to locate my error.
So if u r done suggesting ur own codes ,then look at my code and identify the error.

It has been more than 10 hours since i asked my doubt.
If u can’t clear it,hand it over to someone else ASAP.

Handover this to some other TA if u are not replying.

@D19APPPP0016 your code is giving wrong answer when n is even because when n is even you have to find median like this
int median(int arr[], int n)
{
if (n % 2 == 0)
return (arr[n / 2] +
arr[n / 2 - 1]) / 2;
else
return arr[n / 2];
}
but you are simply taking median as median=arr[n/2];

Please find the error in my code and make it correct and then explain me

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.