help with if n condition evaluation

IndiraP's Avatar, Join Date: Nov 2012
Go4Expert Member
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()..!!!
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Can you clarify in which programming language you have seen such codes?
0
IndiraP's Avatar, Join Date: Nov 2012
Go4Expert Member
Quote:
Originally Posted by shabbir View Post
Can you clarify in which programming language you have seen such codes?
In C language sir..
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
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.
0
state's Avatar, Join Date: Sep 2011
Go4Expert Member
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.
0
IndiraP's Avatar, Join Date: Nov 2012
Go4Expert Member
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 ..