My book says that
! expr has the value 1 if the expr has the value 0
So my problem is this. When I run the below code, it solves to 0. But 10 < 5 (i < j) is not true, so it's false, or a "0" value. Thus since there is a ! and the expr is 0, I think this should have solved as 1, not 0. I have a ! in front of a zero expr. Why am I wrong?
The only other thing I can think of is am I supposed to read it like this..... let's say (! i < j), so do I read it as "it's not true that i is less than j", in this case, "it's not true that 10 is less than 5", which is in fact a true statement, thus equal to 1, not 0. Is this the correct way to look at it?
i and j are int variables
i = 10; j = 5;
printf ("%d", !i < j );
! expr has the value 1 if the expr has the value 0
So my problem is this. When I run the below code, it solves to 0. But 10 < 5 (i < j) is not true, so it's false, or a "0" value. Thus since there is a ! and the expr is 0, I think this should have solved as 1, not 0. I have a ! in front of a zero expr. Why am I wrong?
The only other thing I can think of is am I supposed to read it like this..... let's say (! i < j), so do I read it as "it's not true that i is less than j", in this case, "it's not true that 10 is less than 5", which is in fact a true statement, thus equal to 1, not 0. Is this the correct way to look at it?
i and j are int variables
i = 10; j = 5;
printf ("%d", !i < j );