+ 2
Guys please tell me how does it comes
https://code.sololearn.com/crFIz1O78ogS/?ref=app According to me value of ans should be 11 not 12
9 Answers
+ 6
it did not work that way in c++ the compiler incremented i twice before adding the values
it was this way
I = 4
I = 5
I = 6
6 + 6 = 12
+ 6
here's a similar question the value of i was incremented twice just like here
https://www.sololearn.com/Discuss/694235/?ref=app
+ 5
i have explained the Javascript behaviour a little check that you will understand a little in the code.
//not great at explanation ask about the JS example I will tell.
about c++ it's related to compiler .
+ 4
it's some compiler quirk from c++.
the same logic on JavaScript gives a little different answer
https://code.sololearn.com/cL2G2m34vtCQ/?ref=app
https://code.sololearn.com/WDL323eYSVtv/?ref=app
+ 1
Answer is 11 18 26 on javascript
+ 1
Eg: i=4;
Ans=++i + ++i + ++i
++i=5
++i=6
++i=7
Ans=7+7+7
=21 but answer should be 18
0
I understood how does it works in javascript
But in c++ i=4
Then ++i=5
So ans=++i + ++i
=5+6
=11 not 12
0
So according to the value ans2 will be 21
0
@lord krishna your theory will only work for 2 oprands not for 3