Search Your Question

Write a program to swap between two numbers without third variable

Ans : 

For Int : 

var x = 5
var y = 7

x = x + y
y = x - y
x = x - y

print(x)
print(y)


For Other Types :

var a = "a"
var b = "b"
(b, a) = (a, b)



No comments:

Post a Comment

Thanks