Pointers Arithmetic

Can you explain output?
According to me output lines should be opposite

Hi @2000bhaveshkumar
First of all we are passing x and y to swap function but there is no change in them when we print them because x and y are not passed by reference so the changes that are made to x and y remains in the swap function only. But here if we add & in the swap function definition like void swap(char *&x, char *&y) then the values of x and y will change.

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.