+ 12
Can anyone explain how the output has come?
When I do the 5 parts of the code separately I am getting output as 5 3 3 4 5 But when I combine all in one line it is giving output as 6 5 6 5 5 Can anybody explain why? https://code.sololearn.com/caL98lUPp1w3/?ref=app
6 ответов
+ 10
Avinesh so you telling that there is no reason for the output to come as so.
and I also want to tell you that the question I posted is a bit different from the question about which you are talking of. I asked to print value after each increment/decrement.
+ 8
Avinesh I saw these posts but didn't get the answer for the second part of code. Could you please explain.
+ 5
You can read the compiler warning, it is an undefined behaviour. It is discussed here.
https://www.sololearn.com/Discuss/2284550/?ref=app
https://www.sololearn.com/discuss/2111410/?ref=app
+ 4
Its depend on compiler how compiler its calculate. i tried in three different compiler am getting different output .
+ 3
That is what undefined means i guess.
Read the below links for more clarity.
https://en.wikipedia.org/wiki/Sequence_point
https://stackoverflow.com/questions/4176328/undefined-behavior-and-sequence-points
+ 1
Puthur Harthik Read from the 2nd thread that I shared. The order of evaluation is not so well defined in C and C++ unlike other languages like java etc.