Close
Topic list
Swap Number Without Temporary Variable
EASY
15 mins
Bit Manipulation
Topics (Covered in this problem)
Problem solved
Skill meter
Bit Manipulation
-
-
Other topics
Problem solved
Skill meter
Strings
-
-
Matrices (2D Arrays)
-
-
-
-
Sorting
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Dynamic Programming
-
-
Greedy
-
-
Tries
-
-
Arrays
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

# Swap Number Without Temporary Variable

Contributed by
Dhruv Sharma
Easy
0/40
Avg time to solve 15 mins
Success Rate 85 %
Share

## Problem Statement

#### Swap means the value of βXβ and βYβ must be interchanged. Take an example βXβ is 10 and βYβ is 20 so your function must return βXβ as a 20 and βYβ as a 10.

Detailed explanation ( Input/output format, Notes, Constraints, Images )
##### Sample Input 1:
``````2
10 12
-4 -5
``````
##### Sample Output 1:
``````12 10
-5 -4
``````
##### Explanation of sample input 1:
``````Test Case 1:
Given βXβ is 10 and βYβ is 12. After swapping βXβ will be 12 and βYβ will be 10.

Test Case 2:
Given βXβ is -1 and βYβ is -5. After swapping βXβ will be -5 and βYβ will be -4.
``````
##### Sample Input 2:
``````2
1 2
0 -5
``````
##### Sample Output 2:
``````2 1
-5 0
``````
Auto
Console