+ 1
What is the output of i=++i + ++i in C , provided the initial value of i is 2?
8 Answers
+ 2
Even if the variable is the same?
I mean, in an expression like
++i + ++j
we don't know if i is incremented before j, but in
++i + ++i
the final value shouldn't depend on the order of incrementation.
+ 1
8 because you pre-increment i twice.
+ 1
AndreaC can you please elaborate the process?
+ 1
You start with i=2, after the first pre-increment you have i=3, after the second one i=4, finaly the addition.
+ 1
I see, I didn't consider the possibility of two different copies of i, thank you đ