1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

What is true or false?

  1. Dec 18, 2011 #1
    1. The problem statement, all variables and given/known data

    in this statement

    if (iarray < 0 && *isigned)

    How do I evaluate that

    the code is in c

    isigned is either 0 or 1

    does it mean that for each value in the array that is less than 0 AND for each value in the array that is less than isigned

    or does it mean for each value in the array AND a some other statement

    && isigned (where isigned is either 0 or 1)

    what does it mean?
    2. Relevant equations



    3. The attempt at a solution
     
  2. jcsd
  3. Dec 18, 2011 #2

    LCKurtz

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member



    I would think isigned must be a pointer and *isigned is the value stored at the address pointed to. So it isn't isigned which is 0 or 1, it is that value at that address that is. The && operator performs a logical AND interpreting that 1 or 0 as TRUE or FALSE.
     
  4. Dec 18, 2011 #3
    Cheers matey potatey
     
  5. Dec 18, 2011 #4

    NascentOxygen

    User Avatar

    Staff: Mentor


    This is not a looping statement. This if statement looks at only one element in the array.

    The && is performed last, after iarray < 0 is evaluated. So it's equal to:
    if ((iarray < 0) && *isigned)

    Also, unless the first condition evaluates as true, then whatever isigned points to is not considered. So isigned need not point anywhere, not until iarray < 0 becomes true (at least as far as evaluation of this statement is concerned).
     
    Last edited: Dec 19, 2011
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: What is true or false?
  1. True probabilities (Replies: 1)

  2. Average true stress (Replies: 1)

  3. Op-amp true or false (Replies: 11)

Loading...