44. Swap Two Values

 Write two functions that swap the values of two integers in different ways:

  • void swapPtr(int* a, int* b) → swaps values using pointers.
  • void swapRef(int& a, int& b) → swaps values using references.
     

The program will call both functions and print the results.
 You only need to implement the two functions.

 

Example
 Input:

5 10

Output:

After swapPtr: a=10 b=5
After swapRef: a=10 b=5

 

Input:

-3 7

Output:

After swapPtr: a=7 b=-3
After swapRef: a=7 b=-3

 

Loading...

Input

5 10

Expected Output

After swapPtr: a=10 b=5 After swapRef: a=10 b=5