+ 3

changing value

a=10; b=20 not using new variable and changing a and b's value the result should be print(a,b) => 20 10 different method( a,b=b,a not using this) and it have to adapt for numbers

13th Mar 2018, 5:19 PM
ģ”°ģ˜ˆģ§„
ģ”°ģ˜ˆģ§„ - avatar
6 Answers
+ 5
a = a+b; b = a-b; a = a-b;
13th Mar 2018, 6:08 PM
cHiRaG GhOsH
cHiRaG GhOsH - avatar
+ 4
You could do this: a = a + b b = a - b a = a - b It does the trick
13th Mar 2018, 6:10 PM
cyk
cyk - avatar
+ 3
@D_B your code works , no doubt. But try to make one of the numbers 0 !!! Code will show error. That's why this method is not preferred.
13th Mar 2018, 6:14 PM
cHiRaG GhOsH
cHiRaG GhOsH - avatar
13th Mar 2018, 6:12 PM
D B
D B - avatar
0
Working on it :D
13th Mar 2018, 6:14 PM
D B
D B - avatar