Saturday, March 14, 2009

Considering a=4 and b=10. Can you swap the values without using any

Question :Considering a=4 and b=10. Can you swap the values without using any
temp variable? The final output should be a=10 and b=4. (Other)


Answer :a = a + b // 4 + 10 = 14
b = a - b // 14 - 10 = 4
a = a - b // 14 - 4 = 10
b = 4
a = 10

No comments: