Computer Science, asked by nayaknikhil457, 2 months ago

if p=10 find p-=p++ + --p​

Answers

Answered by atrs7391
1

Question:

If p=10 find p-=p++ + --p​

Solution:

Given value of p = 10

Given statement is  p-=p-- + --p

Output is -8

Answered by anindyaadhikari13
1

Answer:

  • Output for the question is -10.

Explanation:

Given statements,

p = 10 – (i)

p - = p++ + --p – (ii)

Initially, p = 10

Now, let us evaluate value of p.

>> p - = p++ + --p

>> p = p - (p++ + --p) [Brackets must be given as whole value is subtracted.]

>> p = 10 - (p++ + --p)

>> p = 10 -(10 + --p) [p++ returns 10 and then increments the value of p]

>> p = 10 - (10 + --p) [p becomes 11]

>> p = 10 - (10 + 10) [p becomes 10 as it is pre-decrement, value is decremented by 1 and then added]

>> p = 10 - 20

>> p = -10

Hence, the final value of p is -10.

Similar questions