+ 2

what does it means ?

#include<stdio.h> int main() { int c=2; (--(c*=-(c==c)))*=-(c==c); printf("%d",c); }

4th Feb 2018, 6:14 AM
Ahmed Neerob
Ahmed Neerob - avatar
2 Answers
+ 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.
18th Mar 2018, 7:53 AM
Ahmed Neerob
Ahmed Neerob - avatar
+ 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.
4th Feb 2018, 7:01 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar