Quote Originally Posted by jackson6612 View Post
Code:
if (1 < 2) // as the statement is true therefore it will show "1"
if (1 > 2) // as the statement is false it will show "0"
if (radius of a circle) /* as in this statement you haven't specified any condition therefore it will be interpreted as true always/*
The logic is not correct, the reverse is correct.
The rule is when you have integers
Code:
if (INT) = true (for INT !=0)
if (INT) = false (for INT = 0)
so if the "radius of a circle" is 0 it will be false, not true.

When you have
Code:
if (LOGICAL EXPRESSION)
then the compiler just needs to do
Code:
if (LOGICAL EXPRESSION) = true (for LOGICAL EXPRESSION=true)
if (LOGICAL EXPRESSION) = false (for LOGICAL EXPRESSION=false)
Now, I don't see why the compiler will make a logical expression to an integer, then compare that integer with 0 to see if the if-statement is true or not.

The use of the integers is mostly needed in C because there are no boolean type, so when you do something like
Code:
if( trySomething() ) .... ;
then trySomething() will return 0 if it is false or non-zero if it is true and the if-statement will work.