0
if a=5,b=9,then find the value of a+=++a+--b +a
so cna you explain this question
5 Réponses
+ 3
Modification of operand(s) involved in an expression to be evaluated leads to undefined behaviour. The standards doesn't dictate how an evaluation order should perform. That means output is unpredictable, and *may* differ from one compiler to another.
You should see a warning about sequence point issue about that snippet you have if you run it in modern compilers.
https://stackoverflow.com/questions/4176328/undefined-behavior-and-sequence-points
You could check for yourself whether the answer given by Sam was correct, and do so in multiple compilers to see, whether any warning was thrown.
P.S. Please use the tags appropriately ...
https://code.sololearn.com/W3uiji9X28C1/?ref=app
+ 3
You might be interested in this thread – the answer may not only depend on compilerbutalso on programminglanguage:
https://www.sololearn.com/Discuss/2882645/?ref=app
0
Thanks Sma
0
Sam
- 2
a = a + (++a)+(--b)+a
= 5 + 6 + 8 + 5
= 24