21.4k views
4 votes
If this procedure is called with xp equal to yp (i.e. both xp and yp point to the same integer) what effect will it have compared to the situation where xp and yp point to different integers?

User Raduken
by
4.8k points

1 Answer

1 vote

Answer:

The value is always zero .

Step-by-step explanation:

If both have different values

a = 10, b = 20

As

xp = xp+yp so

xp = 30

yp =20

As

yp = xp-yp

so xp=30

yp=10

Now

xp = xp-yp = 20

so we can conclude that both a and b have been interchanged.

if both direct to same object

then

xp = xp+yp

so xp = 40

yp =40

Now

yp = xp-yp

so xp=0

yp=0

and

xp = xp-yp = 20

User Nick Lee
by
4.0k points