Swap Using Pointers
You are given two integers A and B.
Implement a function named swapValues that:
- Takes two Integer pointers as parameters i.e. A and B
- Swaps the values of A and B using pointers
Note: The output will be handled in driver code.
Example 1:
Input: A = 3, B = 7
Output: 7 3
Explanation:
A = 3, B = 7, after swap the value of A = 7, B = 3
Example 2:
Input: A = -5, B = 10
Output: 10 -5
Explanation:
A = -5, B = 10, after swap the value of A = 10, B = -5
Now Your Turn!
Pick the correct output for the given inputInput: A = -10, B = -10
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- -100 <= A, B <= 100