+ 2
what does it means ?
#include<stdio.h> int main() { int c=2; (--(c*=-(c==c)))*=-(c==c); printf("%d",c); }
2 Antworten
+ 1
But compiler showed 3
I thought that logic in this way.
(--(c*=-(c==c)))*=-(c==c)
(--(c*=-(1)))*=-(1)
(--(-c))*=-(1)
(--(-2))*=-(1)
(-3)*=-(1)
3
the answer would be 3.
+ 5
c==c is always 1, as it's a numerical representation of the boolean "true" value. So it's basically:
--(2*(-1)*(-1)) so -2 * -1 (all minuses cancel each other out).
So 2.