Swap Two Numbers Without Using a Third Variable

Your task is to swap two given numbers without utilizing an additional variable and print the swapped values.

Input:

The first line contains an integer 't', indicating the number of test cases.
The following lines each contain two integers 'a' and 'b'.

Output:

For each test case, output the swapped values of 'a' and 'b' as a single line.

Example:

Input:
2
3 7
10 5
Output:
7 3
5 10

Constraints:

  • 1 <= 't' <= 100
  • -105 <= 'a', 'b' <= 105
Note:
Focus only on implementing the given function, as output handling is already managed.
Be the first one to answer
Add answer anonymously...
Wunderman Thompson Commerce Java Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter