# Boolean Question(s);

• 01-09-2008
computerquip
Boolean Question(s);
My very first question has to do with the tutorial quiz for If statements.

1. Which of the following is true?
A. 1
B. 66
C. .1
D. -1
E. All of the above

I picked 1. It doesn't exactly specify in the tutorial what happens to a number other than 0 and 1. I could have sworn that numbers other than 1 led to false by default. I'm probably wrong like usual about programming but I would just like a definite answer.

2. Which of the following is the boolean operator for logical-and?
A. &
B. &&
C. |
D. |&

I would like to know what the difference between logical-and and and is. I guessed B which is correct which leads me to assume they are the same thing. Am I correct? Again, it doesn't specify in the tutorial so I'm led to ask this probably simple question.
• 01-09-2008
robatino
1) It's a little ambiguous. If a number is used in an if or while statement, then nonzero is true and zero is false. On the other hand, if boolean true or false is converted to a number, then true becomes 1 and false becomes 0. So complain to whoever wrote the quiz. I'm guessing the correct answer is supposed to be E but it's not totally clear.

2) Logical and is &&. Bitwise and is &. Google for "logical and" and "bitwise and".
• 01-09-2008
robwhit
They are not the same, in fact, I wrote an example program to demonstrate this just today:

http://cboard.cprogramming.com/showp...0&postcount=14
• 01-10-2008
cpjust
E & B.
• 01-11-2008
computerquip
Thanx! This helped a lot.