Bubble sort execution

in Bubble sort program, we call the bubble_sort(a,n) function which sorts the array. After calling the function , we print the elements of the array, so the sorted elements get printed. I wanted to know how the function is able to change the elements in the array in main() as the scope is different and we have learnt earlier that change of variable inside the function couldn’t change it’s value outside it.

@himanshigupta579 Array is passed by reference which means that whatever changes which are being made in the bubble sort function will be reflected back in the main.

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.