// Method 1: With temporary variable
temp = A
A = B
B = temp
// without temporary variable
// Method 2: Addition and subtraction
A = A + B
B = A - B
A = A - B
// Method 3: Muitply and Divide
A = A * B
B = A / B
A = A / B
X= 25 (First number), Y= 23 (second number)
Swapping Logic:
X = X + Y = 25 +23 = 48
Y = X - Y = 48 - 23 = 25
X = X -Y = 48 - 25 = 23
and the numbers are swapped as X =23 and Y =25.
var a=window.prompt('enter a number')var b=window.prompt('enter a number')var a=a+b;var b=a-b;var a=a-b;console.log ("value of a is",a);console.log('value of b is',b);