Doubt on why i get the output as zero

Code
include<bits/stdc++.h>
using namespace std;
int main() {
int n;
cin>>n;
int a[1000]={0};
int b[1000]={0};
int c[1000]={0};
for(int i=0;i<n;i++)
{
cin>>a[i];
}
for(int i=0;i<n;i++)
{
cin>>b[i];
}
for(int i=0;i<n;i++)
{
c[i]=a[i];
}
for(int i=n;i<2n;i++)
{
c[i]=b[i];
}
int sc=2
n;
sort(c,c+sc);
if(sc%2==0)
{
return (int)c[sc/2]+c[(sc+1)/2];
}
else
{
return c[sc/2];
}
return 0;
}

Hello @shyama you have to use cout instead of return and also what is the logic you are using?
because first youhave to arrange the elements of the both the arrays into single array oi the sorted format.
then you have to find the median.

yes , I have copied both a and b into c and then sorted the array

for(int i=0;i<n;i++) { c[i]=a[i]; } for(int i=n;i<2*n;i++) { c[i]=b[i]; }

@shyama check this is the updated code:


i have commented the mistake:
Happy Learning!!

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.