+ 5
Challenge :In how many ways you can swap two values?
eg. If x=2 and y=3 then after swaping x becomes 3 and y becomes 2
7 Réponses
+ 11
m1 ) int x=2,y=3;
x=x+y;
y=x-y;
x=x-y;
m2) int x=2,y=3,t=0;
t=x;
x=y;
y=t;
m3) int x=2,y=3;
if (x !=0 && y !=0)
x *=y;
y=x/y;
x=x/y;
m4) ... u can make infinite methods 😂..😅
+ 3
https://code.sololearn.com/cjwyyo9RkDGL/?ref=app
Well i believe i've done what the challenge requires
+ 3
wow I am getting new ideas
+ 2
very good
+ 2
it's good
+ 2
This is also new idea
https://code.sololearn.com/cW29Hr4AaPRK/?ref=app
+ 1
in python
x=4
y=5
x , y = y , x