View Miscellaneous problems
Question: Write a program to swap 2 numbers? Input: a = 4, b = 19 Output: a = 19, b = 4 We will try to discuss the different ways to swap 2 numbers. To understand how swapping works, please visit this post. Method 1 : Using a temporary variable Method 2 : Without a temporary variable Method 3: Using multiplication and division IMP: It is necessary here that numbers should be non-zero Method 4: Using Bitwise XOR (^) Method 5: Swapping in single line using arithmetic operator Method 6:…