+ 1
please help!! write a program to swap value of two variables without using third variable
3 Answers
+ 4
A = A + B
B = A - B
A = A - B
+ 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;
}
- 2
swapping of two numbers x & y. introduce a new variable z.
z=x
x=y
y=z