+ 3

What is value of a in the given code

Does Swapping reference, swaps values inside? https://code.sololearn.com/ccxDZ6fqcpiN/?ref=app

29th Dec 2018, 1:37 PM
Aaditya Deshpande
Aaditya Deshpande - avatar
1 Answer
+ 3
You swap pointers, not values, inside the function, so no change occurs outside. In order to swap values there should be something like int t = *ptr1; *ptr1 = *ptr2; *ptr2 = t;
29th Dec 2018, 1:57 PM
Микола Федосєєв
Микола Федосєєв - avatar