0

why this output? int x=3; x=++x + ++x + ++x; cout<<x; //output==16 ?

13th Jun 2016, 12:41 PM
Lekhraj Singh
Lekhraj Singh - avatar
6 Réponses
+ 3
there is a rule that expalin that a variable can not be upadated twice in an expression. if such things happen the result depends upon the implementation of that specific compiler .
13th Jun 2016, 12:53 PM
Ganesh K
Ganesh K - avatar
+ 1
something wrong!
13th Jun 2016, 2:22 PM
Utpal Kumar
Utpal Kumar - avatar
0
so we can't forecast result in the same examples?
13th Jun 2016, 1:04 PM
Michael Shumsky
Michael Shumsky - avatar
0
OK this output depends on compiler
14th Jun 2016, 8:08 AM
Lekhraj Singh
Lekhraj Singh - avatar
- 1
yeh something wrong its ouput should be 15
13th Jun 2016, 5:33 PM
Mainak Bhattacharya
- 1
it should be 18
14th Jun 2016, 6:07 AM
Vivek Sharma
Vivek Sharma - avatar