Computer Science, asked by ananthuad, 10 months ago

int x =20, y = 10, z; What is the value of z in z = ++x * (y – –) – y ? Show the steps.

Answers

Answered by JaintiGusain
94

z=++x*(y--) - y

z=21*10-9

z=210-9

z=201(ans)

Hope this will help you

Answered by qwvilla
5

Given: z = ++x * (y – –) – y ,   x =20, y = 10

To find The value of z

Solution: The above expression is an example of the increment and decrement which is a unary operator where we perform addition and subtraction. This increment and decrement can occur in two forms for an expression, one is 'pre' (increment or decrement) in which the operation(increment or decrement) is done first, then used the expression. The other is 'post' (increment or decrement) in which the operation(increment or decrement) is done at last, at first the variable is read.

Now from above, we have

z = ++x * (y – –) – y

⇒z=(20+1)*(10-0)-9  [substituting the values of x and y and initiating pre-increment and post-decrement, which can be seen with the immediate next value of y, becomes 9 from 10]

⇒z=(21*10)-9

⇒z=210-9

⇒z=201

Hence the value of z is 201.

Similar questions