Answers for "How to swap two numbers"

1

How to swap two numbers

// 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
Posted by: Guest on June-11-2021

Code answers related to "How to swap two numbers"

Browse Popular Code Answers by Language