New update is available. Click here to update.
sidenav-btnClose
Topic list
Swap Two Numbers
EASY
10 mins
470 upvotes
Other topics
Problem solved
Skill meter
Strings
-
Matrices (2D Arrays)
-
Sorting
-
Binary Search
-
Linked List
-
Stacks & Queues
-
Trees
-
Graph
-
Dynamic Programming
-
Greedy
-
Tries
-
Arrays
-
Binary Search Trees
-
Heap
-
Bit Manipulation
-

Swap Two Numbers

Contributed by
Shrey Pansuria
Easy
Avg time to solve 10 mins
Share
470 upvotes

Problem Statement

Take two numbers as input and swap them and print the swapped values.

Detailed explanation ( Input/output format, Notes, Constraints, Images )
Sample Input 1:
2
1 2 
3 4
Sample Output 1:
2 1
4 3
Explanation For Sample Input 1:
The output of the above test case is 2 1 for the first test case.
The output of the 2nd test case is 4 3.
Sample Input 2:
2
5 6
7 8
Sample Output 2:
6 5
8 7
Explanation For Sample Input 2:
The output of the above test case is  6 5 for the first test case.
The output of the 2nd test case is 8 7.
Reset Code
Full screen
copy-code
Console