0

J=7..?? how it's working ? I m unable to evaluate or predict answers of such expression?plz guide me to clear my doubt?

https://code.sololearn.com/cVTEiOCD7VYy/?ref=app

9th Jun 2018, 5:27 PM
Deepak Bhalode
Deepak Bhalode - avatar
5 ответов
+ 1
j = ++i + ++i + i; j=A+B+C is evaluated as follow: j = (A + B) + C; 1) Evaluate A : increment i -> now i is 1 2) evaluate B : increment i -> now i is 2 3) evaluate A+B : add i to i ->That's 4 This sum is stored in new memory location separately to i, so is not changed when i is incremented again. 4) Evaluate C : increment i again -> now i is 3 5) Add C (the last value of i) to the first sum : 4+3 Result is 7
9th Jun 2018, 6:11 PM
ifl
ifl - avatar
9th Jun 2018, 5:30 PM
Deepak Bhalode
Deepak Bhalode - avatar
+ 1
tysm Sir. ..since 2 nits I ws trying to find the conceptual reason
9th Jun 2018, 6:27 PM
Deepak Bhalode
Deepak Bhalode - avatar
+ 1
Some more examples here: https://code.sololearn.com/ceYh2erq9U7y/?ref=app (you may want to link to yours in the comments!)
9th Jun 2018, 6:31 PM
ifl
ifl - avatar
0
(...and, one should really *NOT* want to use this in production code !!! :-D)
9th Jun 2018, 6:36 PM
ifl
ifl - avatar