0

if a=5,b=9,then find the value of a+=++a+--b +a

so cna you explain this question

30th Sep 2021, 5:21 PM
Kuber Bansal
Kuber Bansal - avatar
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
30th Sep 2021, 5:42 PM
Ipang
+ 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
30th Sep 2021, 6:56 PM
Lisa
Lisa - avatar
0
Thanks Sma
30th Sep 2021, 5:26 PM
Kuber Bansal
Kuber Bansal - avatar
0
Sam
30th Sep 2021, 5:26 PM
Kuber Bansal
Kuber Bansal - avatar
- 2
a = a + (++a)+(--b)+a = 5 + 6 + 8 + 5 = 24
30th Sep 2021, 5:25 PM
Sam
Sam - avatar