Close
Close

C++, Pointers, Level 1, task 7.

   Dmytro Hrydasov

Write a program to swap the addresses of two variables using pointers.

It is imposible. Programer can’t change the adresses of two variables (its assigned automatically and can not be changed). You can change only their values. So what is the point in this task?


Answers

  •   

    You don’t need to swap the addresses. Swapping address means swapping with respect to their values which means that if the values are 5 and 2 then the address of 5 should be the previous address of 2 and vice-versa. So, it is basically swapping of values and swapping addresses represents the address with respect to variables.


    • Oh ok, now it clear...
      - Dmytro Hrydasov

Ask Yours
Post Yours
Write your answer