help with if n condition evaluation

Go4Expert Member
13Nov2012,22:14   #1
IndiraP's Avatar
i have seen at many places where condition is to be evaluated..
if(a)
{}
if(!a)
{}
for(i=0;!a;i++)
{}
if(1){}
if(!9){}

and things lyk that

can u tell me wat r the various types of conditions of if() n wat datatypes should be "a" for the above cases...???
and i knw the basic functionality of if()..!!!
Go4Expert Founder
14Nov2012,10:11   #2
shabbir's Avatar
Can you clarify in which programming language you have seen such codes?
Go4Expert Member
14Nov2012,12:15   #3
IndiraP's Avatar
Quote:
Originally Posted by shabbir View Post
Can you clarify in which programming language you have seen such codes?
In C language sir..
Go4Expert Founder
14Nov2012,13:09   #4
shabbir's Avatar
Moved thread to C Programming and each of those if statements means checking if the condition is true or false. Integer is 0 is equivalent to false.
Go4Expert Member
14Nov2012,16:09   #5
state's Avatar
Hello IndiraP

Suppose I have the following
Code:
int a=5
if(a)
...
What would such absurd looking loc(lines of code) mean?Well if you look at it closely it means "If the a has a definite value(any value other than zero) then the condition is true else the condition is false".Even a negative value or a floating point value is taken as truth value.
Go4Expert Member
16Nov2012,15:00   #6
IndiraP's Avatar
Quote:
Originally Posted by state View Post
Hello IndiraP

Suppose I have the following
Code:
int a=5
if(a)
...
What would such absurd looking loc(lines of code) mean?Well if you look at it closely it means "If the a has a definite value(any value other than zero) then the condition is true else the condition is false".Even a negative value or a floating point value is taken as truth value.
Thank u ..