Don't we need to pass array by reference?

since the array which gets sorted is the one in the function only and it shoudnt change the one in main

Hello @niketagarwal10,

As we know that the name of the array is a pointer to it’s first element i.e.
for array a[], a is a reference to a[0].

Thus, we need not to pass it by reference. All the changes made in the function will reflect back in the main function.

Hope, this would help.
Give a like if you are satisfied.

1 Like

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.