New update is available. Click here to update.

Last Updated: 27 Jan, 2021

Difficulty: Easy

```
The first line of input contains a single integer 't', representing the total number of test cases.
The second line of input contains two integers 'a' and 'b', representing the second number.
```

```
The first line of output prints the swapped value of 'a' and 'b'.
```

```
You do not need to print anything, it has already been taken care of. Just implement the given function.
```

```
1 <= 'T' <= 10^2
-10^5 <= 'a', 'b' <= 10 ^ 5
Time Limit: 1 sec
```

We can swap values of two variables by using a third variable and instead of that, we can use the arithmetic operation to do it without an extra variable.

The idea is to store the sum of two variables in the first variable. Now if we assign the sum(which is 1st variable) - 2nd variable in the 2nd variable then the value in the 2nd variable will be equal to the 1st variable.

Again assign the first variable equal to the sum(first variable) - 2nd variable(which has a value equal to 1st variable) so 1st variable will now have a value equal to 2nd variable.

Popular Interview Problems: