What is !0 in C?

Viewed 12573

I know that in C, for if statements and comparisons FALSE = 0 and anything else equals true.

Hence,

int j = 40
int k = !j

k == 0 // this is true

My question handles the opposite. What does !0 become? 1?

int l = 0
int m = !l

m == ? // what is m?
5 Answers

!x will be expand to (x==0) so:

  • if x=0 -> !x take value from (0==0) = TRUE (value 1)
  • if x!=0 -> !x take value from (x==0) = FALSE (value 0)
Related