+ 1

please help!! write a program to swap value of two variables without using third variable

14th Aug 2016, 5:40 PM
Kabeer
Kabeer - avatar
3 ответов
+ 4
A = A + B B = A - B A = A - B
14th Aug 2016, 5:49 PM
sidharth arora
sidharth arora - avatar
+ 4
You can use this function to swap two integer numbers: void swap(int &x, int &y) { x = x+y; y = x - y; x = x - y; }
14th Aug 2016, 7:16 PM
GTimo
GTimo - avatar
- 2
swapping of two numbers x & y. introduce a new variable z. z=x x=y y=z
14th Aug 2016, 7:25 PM
Riyas S
Riyas S - avatar