Magic in CPP
Submissions: 1361   Accuracy:

68.62%

  Difficulty: Easy   Marks: 2
Associated Course(s):   Fork CPP

This Module is all about pointers and how they can be cleverly employed to solve typical CPP problems. Later on, we'll dive into OOP and learn Classes that form the base of CPP-OOP.

Given two integers A and B. The task is to swap two numbers. Swapping here means to interchange the values of A and B.
Hint: Swap by reference and pointer.

Input Format:
First line of input contains T, denoting the number of testcases. For each testcase, there will be a single line containing A and B seperated by space.

Output Format:
For each testcase, swap the values of A and B.

User Task:
Your task is to complete the two swap() functions, such that values of A and B gets interchanged.

Constraints:
1 <= T <= 100
1 <= A, B <= 106

Example:
Input:

1
3 5

Output:
5 3

Explanation:
Testcase :
Here, A = 3 and B = 5. After swapping A = 5 and B = 3.

** For More Input/Output Examples Use 'Expected Output' option **

Author: Dhiman Mayank


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.