consider
int a =10;
c = a/a; //c becomes 1.
c= a* + a/a ; //c becomes 1.
c= 5+ a* + a/a ; //c becomes 15.
c = ++a + a++ - --a - a-- + a * + a/a ; //c becomes 10.
Can someone please tell me how the above works ? Especially the a* part. The first one is only for reference.
In this line:
The
+is the unary plus operator. So it is equivalent toThe variable
ais 10, so10 * 10/10is10, not1. Then...is equivalent to
c = 5 + a * a/a, socis now15. ThenPre-increment changes
ato11. Post incrementa++increments to12but yields the old value11, yielding22so far. Then Pre decrement decrements to11and the subtraction yields11. Next, post decrement decrements to10but yields the old value11, and the subtraction yields0. We already know whata * + a/ais,10.