Computer Science, asked by CorradinoPapa8813, 7 months ago

Int x(1,4,8,5,1,4)
Int *ptr,y;
ptr=x+4;
y=ptr-x;

Answers

Answered by uttamrikibe3
5

Answer:

Just apply some simple algebra

if ptr = x + 4 and y = ptr - x therefore y = (x + 4) - x hence y = 4 + x - x thus y = 4 + 0 y = 4

Edit: Addressing the comment

Explanation:

hope it will help ....

plz follow me and mark as brainliest

Answered by amikkr
0

Here, x = (1,4,8,5,1,4)
We have been given a pointer and a variable y.
ptr = x + 4
∴ The values that the pointer will be pointing will be the values of x + 4

For x = 1 ; ptr = 1 + 4       ⇒ ptr = 5
For x = 4 ; ptr = 4 + 4       ⇒ ptr = 8
For x = 8 ; ptr = 8 + 4       ⇒ ptr = 12
For x = 5 ; ptr = 5 + 4       ⇒ ptr = 9

Now, the value of y is determined by
y = ptr - x ;
∴The values of y will be
For ptr = 5 and x = 1           ⇒ y = 5 - 1       ⇒ y = 4  
For ptr = 8 and x = 4           ⇒ y = 8 - 4       ⇒ y = 4
For ptr = 12 and x = 8           ⇒ y = 12 - 8       ⇒ y = 4
For ptr = 9 and x = 5           ⇒ y = 9 - 5       ⇒ y = 4

The value of y for any value of x = 4.

#SPJ2

Similar questions