1. Limited time only! Sign up for a free 30min personal 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!

Homework Help: 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


    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


    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
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook