1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

searching for short conditional statement examples

Discussion in 'C' started by Florentino Enriquez, Sep 27, 2012.

  1. Florentino Enriquez

    Florentino Enriquez New Member

    Joined:
    Sep 27, 2012
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    h! I'm just a student and I'm looking for ten short examples of conditional statement,,. Can you help me?
     
  2. hobbyist

    hobbyist New Member

    Joined:
    Jan 7, 2012
    Messages:
    141
    Likes Received:
    0
    Trophy Points:
    0
    stuff like if a equals b or a greater than c then take this path else if a equals b and a is less than c then take this path else ... other conditional tests, switch statements, sentinel controlled loops, and such.
     
  3. HARIT

    HARIT New Member

    Joined:
    Jul 16, 2011
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    0
    expression1 ? expression2 : expression3

    if expression1 satisfied(i.e. nonzero) then only expression2 will return, otherwise expression3 will return.

    Ex1: 1?"TRUE":"FALSE";. here you will get "TRUE". because the expression1 is a nonzero value.
    Ex2: int i=1; (i-1)?"TRUE":"FALSE";. here you will get "FALSE". because the expression1 i.i (i-1) gives a nonzero value.
     

Share This Page