Assume Boolean values have been assigned to A, B, and C as
A= true; B= false; C= True
Indicate wether it is true or false.
(A && B) || (A && C)
How would I go about doing this?
Assume Boolean values have been assigned to A, B, and C as
A= true; B= false; C= True
Indicate wether it is true or false.
(A && B) || (A && C)
How would I go about doing this?
Evaluate the (A && B) part
Evaluate the (A && C) part
Evaluate those two results above combined with ||.
"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens
haha, can't you copy your homework off of some dorky kid near you? is that even computer science homework?
either way, i'll explain it.
the equation in question is as follows, assuming A and C are true, and B is not.
here are some rules about dealing with boolean:Code:(A && B) || (A && C)
in an "and" statement (&&), if any of the values at all are false, the
whole thing is false.
in an "or" statement (||), it checks the value of the first piece of code, and if it is true, it will not read the second piece of code; it will simply mark itself "true." however, if the first segment of code is false, then it will check the second segment. if either of these segments are true, the entire statement is true.
so, in this case, because the whole line of code exists within an "or" statement, we look at the first one first, then if it's false, we look at the second one, and if either of them were true, it's true.
so, the first one, a && b = true && false. one of them is false, so the first segment is false. let's look at the second one.
A && C = true and true, that means this section is true, because none of the values are false.
so, we've got that the first value is false, and the second is true.
the or statement is true if any of the results are true, and one of them is, therefore the entire statement is true.
-n3v
Last edited by n3v; 04-06-2006 at 07:23 AM.
It sounds like Electronics homework to me.
Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.
- Mike McShaffry
How to write Boolean expressions in the real world:
Z (output) = A.B+A.C
+ = or
. = and
real world? i assume that's electronics lingo. i've never seen boolean expressions written like that. i thought they were represented with weird little symbols when you deal with them in math.
Hahah thanks guys. Makes more sence now.
yep it was electronic lingo
How do you represent NOT in ASCII - afaik there's no bar.
I guess you could do
_
B.(A+C)
But that's wasting a line.
Meh.
EDIT: wtf I put that underscore over the C, over the goddam C!
Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.
- Mike McShaffry
I don't think computers were designed to make boolean expressions.
haha. instant classic.Originally Posted by bumfluff
hey, wait, i know what you mean:
0 0
1
0001
nope, expressions don't work very well in boolean.
Last edited by n3v; 04-06-2006 at 09:51 AM.
IS that not binary that your are trying to write there?
¬ is the not symbol. It's not part of tha ASCII character set, but it might be part of some 8-bit Windows character set. ~ is sometimes used as a not symbol, too (and I'm not talking about C; I'm talking about in a math class on a chalkboard), so I recommend using that for logic. For and and or, you could use /\ and \/, but base-2 modular arithmetic + and * are equivalent. (And what's with using a period for multiplication?)
There are 10 types of people in this world, those who cringed when reading the beginning of this sentence and those who salivated to how superior they are for understanding something as simple as binary.
Well in the electronic terms that me and ahluka were talking about not is a score over the letter.
regardless, it doesn't really matter, because we're just using it in c++, where thankfully it's a lot simpler. sort of.
and yeah, that was binary. binary was kind of a representation of boolean values there though. or something.
the thing is though, the only thing computers can really do is make boolean expressions. in binary.