Computer Science, asked by poojarajeevan2006, 2 months ago

If int y=20 then find int z= (++y*(y+++5))​

Answers

Answered by Anonymous
1

Initial Value of y is given as:

y = 20

We have to find:

=> The value of z after calculation.

Concepts used with explanation:

=> Postfix increment : Here, the "++" is added after the variable, it increments the value of the variable by 1 and the new value is stored in the variable but is does NOT return the incremented value to the expression.

=> Prefix increment: Here, the "++" is added before the variable, it increments the value of the variable by 1 and the new value is stored in the variable and also returns the incremented value to the expression.

Calculation:

=>  int z= (++y*(y+++5));

=> int z = ( ++20*(y++ + 5));

=> int z = ( 21*(y++ + 5)); (Prefix increment: y = 21 value returned to expression).

=> int z = ( 21*(21++ + 5)); (Postfix increment: y = 22 value not returned to expression)

=> int z = ( 21*(21 + 5));

=> int z = ( 21*26);

=> int z = (546 );

=> So, the value of z will be 546 and the value of y will be 22 .

More to know:

=> Postfix decrement : Here, the "--" is added after the variable, it decrements the value of the variable by 1 and the new value is stored in the variable but is does NOT return the decremented value to the expression.

=> Prefix decrement: Here, the "--" is added after the variable, it decrements the value of the variable by 1 and the new value is stored in the variable and also returns the decremented value to the expression.

Similar questions