please help with with basic c++ hw

Topplayer

Senior member
Jan 11, 2006
444
0
0
hey guys,
I really need help bad. i cant figure out how to do this. i was wondering if someone could help,i really appreciate it. ok so the problem goes as stated

given three bool variables p,q and r provide complete truth tables for the following expressions
2.1)
p && q

2.2)
!(p||q||r)

2.3)
!(p && r)



im not looking to cheat because i normally do all my work but i cant figure out how to do this with out the values of the variables, can some one please help me
 

AMCRambler

Diamond Member
Jan 23, 2001
7,715
31
91
Technically not even really C++, except for the boolean variable part. They're just looking for truth tables. I'd take a stab, but I was horrible with truth tables. They just never made sense to me. So I would end up hindering you more than helping. Check out wikipedia for some help here.
 

Topplayer

Senior member
Jan 11, 2006
444
0
0
but it doesnt say that i can pick values. it says given three bool variables. you think i can just pick values?
 

tfinch2

Lifer
Feb 3, 2004
22,114
1
0
Originally posted by: Topplayer
but it doesnt say that i can pick values. it says given three bool variables. you think i can just pick values?

Don't be dense. This isn't rocket surgery. You're not really picking values, you're writing all of the possible combinations of T/F or 1/0
 

Topplayer

Senior member
Jan 11, 2006
444
0
0
so if im alittle stubborn ive been awake since yesterday. im gonna use 1 for p and 0 for q what should i use for r?
 

z0mb13

Lifer
May 19, 2002
18,106
1
76
Originally posted by: tfinch2
Originally posted by: Topplayer
but it doesnt say that i can pick values. it says given three bool variables. you think i can just pick values?

Don't be dense. This isn't rocket surgery. You're not really picking values, you're writing all of the possible combinations of T/F or 1/0

another hint: with n variables, there are 2^n possible combinations.

2 variables: 2^2 = 4 possible combinations
3 variables: 2^3 = 8 poss comb
etc
 

z0mb13

Lifer
May 19, 2002
18,106
1
76
Originally posted by: Topplayer
so if im alittle stubborn ive been awake since yesterday. im gonna use 1 for p and 0 for q what should i use for r?

look at my post above
 

tfinch2

Lifer
Feb 3, 2004
22,114
1
0
p q r !(p||q||r)
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1

There are 3 variables, so there are 2^3 possible combinations of T/F, then you fill in the truth table for the last column. If this doesn't make sense, it's time to go to office hours.
 

Aikouka

Lifer
Nov 27, 2001
30,383
912
126
Originally posted by: tfinch2
p q r !(p||q||r)
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1

There are 3 variables, so there are 2^3 possible combinations of T/F, then you fill in the truth table for the last column. If this doesn't make sense, it's time to go to office hours.

Don't forget, a lot of people prefer that you show your steps in between (or what's considered a full truth table). Using the above example:

p q r p||q (p||q)||r !((p||q)||r))
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1

I added the extra parenthesis for simply showing the flow, although the order of operations should be understood.