1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

help with if n condition evaluation

Discussion in 'C' started by IndiraP, Nov 13, 2012.

  1. IndiraP

    IndiraP New Member

    Joined:
    Nov 10, 2012
    Messages:
    41
    Likes Received:
    2
    Trophy Points:
    0
    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()..!!!
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,276
    Likes Received:
    364
    Trophy Points:
    83
    Can you clarify in which programming language you have seen such codes?
     
  3. IndiraP

    IndiraP New Member

    Joined:
    Nov 10, 2012
    Messages:
    41
    Likes Received:
    2
    Trophy Points:
    0
    In C language sir..
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,276
    Likes Received:
    364
    Trophy Points:
    83
    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.
     
  5. state

    state New Member

    Joined:
    Sep 14, 2011
    Messages:
    30
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  6. IndiraP

    IndiraP New Member

    Joined:
    Nov 10, 2012
    Messages:
    41
    Likes Received:
    2
    Trophy Points:
    0
    Thank u ..:)
     

Share This Page