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?
Printable View
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 ||.
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
It sounds like Electronics homework to me.
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!
I don't think computers were designed to make boolean expressions.
haha. instant classic.Quote:
Originally Posted by bumfluff
hey, wait, i know what you mean:
0 0
1
0001
nope, expressions don't work very well in boolean.
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?)
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.