Translate to english

T

Tavish Muldoon

Hello,

Would someone be able to explain what the resultant would be of this statement:

int i = 2;
int j = 3;
int k = 4;

i += j += ++k;


Would some one be able to translate this into 'english'?

I see it as 'add 1 to k' which now equals 5
then 'add 5 to j' which is 3+5=8
then 'add 2' which is the value of i
for a grand total of 10.

Is this correct?

Thanks,

Tmuld.
 
E

Elie De Brauwer

Hello,

Would someone be able to explain what the resultant would be of this statement:

int i = 2;
int j = 3;
int k = 4;

i += j += ++k;


Would some one be able to translate this into 'english'?

I see it as 'add 1 to k' which now equals 5
then 'add 5 to j' which is 3+5=8
then 'add 2' which is the value of i
for a grand total of 10.

Is this correct?

k=k+1;
// k = 5
j= j + k;
// j = 8
i= i + k;
// i = 10;

You assumption was correct, but the easiest way to be sure is by coding it.

my 2 cents

--
Elie De Brauwer
http://www.de-brauwer.be

No animals were hurt and no microsoft products were used during the
creation of this e-mail
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,190
Latest member
ClayE7480

Latest Threads

Top