Computer Science, asked by tanyavarshney, 7 months ago

given the initial value of a= 10 k=2in the following expressions : k+=a++ + ++a/2; write the final value of k and a​

Answers

Answered by RuwaisnZaid
2

Answer:

k = 11 a= 10

Explanation:

this could be the answer

Answered by samanwitapaul07
1

Answer:

The final values of k and a are : k = 18; & a = 12;

Explanation:

Initial values :

a = 10;

k = 2;

Substitution of the vlaues in the equation :

k+=a++ + ++a/2;

Java in case of shorthand operator adds the value of k to the equation after solving the equation.

We can write as,

k=k+(a++ + ++a/2);

k=2+(10 + a/2); (a remains 10 due to post increment)

k=2+(10 + 12/2); (a first becomes 11 then due to the pre increment, it becomes 12)

k=2+( 10 + 6);

k=2+(16);

k=18;

The final values :

k = 18;

a = 12;

Similar questions