Answers for "Swap Numbers"

0

Swap Numbers

Numbers -- Swap Numbers
Swap two variable values without using a third variable
 
Solution 1:
int  a = 10;      int  b  = 20;
a = a +b;
b = a - b;
a = a - b;
 
Solution 2:
int  a = 10;      int  b  = 20;
a = a^b;
b = a^b;
a = a^b;
Posted by: Guest on September-29-2021

Browse Popular Code Answers by Language