0

Why the first output is 1 0 but the second is 0 1??

https://code.sololearn.com/c4q8eV0m3wJM/?ref=app

24th May 2019, 6:25 AM
Nitin Bhattacharyya
Nitin Bhattacharyya - avatar
4 Réponses
+ 4
increment operation in printf is done from right to left
24th May 2019, 6:27 AM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 2
the problem is that, it's incremented normally, but printed in reverse, though I haven't figure out why it work that way, but that's how it works, let me call on my guru ~ swim ~ to shed more light on this
24th May 2019, 6:32 AM
✳AsterisK✳
✳AsterisK✳ - avatar
0
But then shouldn't the second printf give 0 0 as the second printf is (i++,i)??
24th May 2019, 6:29 AM
Nitin Bhattacharyya
Nitin Bhattacharyya - avatar
0
It's because when you first use I, i++ at that time first value is look like this 0, 0++ so in this statement I=0 is post increment by 0++ so value of i become 1 but 0++ is still give 0 So output 1 , 0 In other statement i++, i 0++, 0 First statement 0++ will give 0 and next time post increment give 1 so output comes as 0, 1
24th May 2019, 6:41 AM
Abhi