Look up de Morgan's law.∴Your last formula contains double negatives, but they eventually resolve to give you the test you wanted.
Eric Flynn wrote:. . . it works . . . but i dont really understand why
None of them. The formula with the && is better, but what about this?This isn't so much a C++ question as a general question about Boolean algebra. Don't people teach Boolean algebra any more?
which would you prefer?
Campbell Ritchie wrote:but what about this?
Eric Flynn wrote:
... but you could also do this...
but i dont really understand why
you wrote:... and it works
Eric Flynn wrote:hi Junilu Lacar it seemed to work ok with me and the loop terminated when 1 to 4 were entered, am i missing something?
Eric Flynn wrote:so is && preferred to|| , || does it just depend on the situation && what you are trying to do?
Yes, I think you are right.
Junilu Lacar wrote: . . . . I think you meant
. . ..
. . . and the fact that every logic book I have read seems to have a slightly different notation doesn't help.
. . . if the notation Campbell gave looks strange . . ..