233k views
3 votes
Assume that ip , jp , and tp have all been declared to be pointers to int and that result has been declared to be an array of 100 elements . Assume further that ip has been initialized to point to an element in the first half of the array and that jp has been initialized to point to an element in the second half of the array .Write some code that makes jp point to the element that ip was pointing to and that makes ip point to the element that jp was pointing to.Instructor Notes: Here, you are swapping the pointers, not the values they point to.

User Jungmin
by
8.6k points

1 Answer

4 votes

Answer:

The code to this question can be given as:

code:

tp = ip;

ip = jp;

jp = tp;

Explanation:

In this question, it is defined that write code for swapping values that swap the pointers, not the values they point to. So in this code, we assume that all the variable and its value is defined. we simply use the swapping rule that is the first value holds in the new variable and second value hold on the first variable and in the last second variable holds the value of the new variable. In this code, the value will be interchanged or swapped.

User Zhang Qinglian
by
8.4k points