Question

In: Computer Science

Write a C++ program to construct the truth table of P ∨¬(Q ∧ R) If you...

Write a C++ program to construct the truth table of P ∨¬(Q ∧ R)

If you could include comments to explain the code that would be much appreciated!!! :)

Thank you so much!

Solutions

Expert Solution


#include <iostream>

using namespace std;


int main()
{
int x,y,z;//x,y,z are p,q,r variables
cout<<"P\tQ\tR\tPV~(Q∧R)";//displays header of the table

for(x=0;x<=1;++x)//proposition p value can be 0 or 1. x takes 0 or 1
for(y=0;y<=1;++y)//proposition q value can be 0 or 1
for(z=0;z<=1;++z)//proposition r value can be 0 or 1
{
/*PV~(Q∧R) formula can be written as p+~(qr)in formal language
in programmaing language can be written as p+!(q*r)
*/
if(x+!(y*z)==2) //2 is not present in the proposition logic hence it is considered as 1
cout<<"\n"<<x<<"\t"<<y<<"\t"<<z<<"\t1";
else
cout<<"\n"<<x<<"\t"<<y<<"\t"<<z<<"\t"<<(x+(!(y*z)));//formula calculates and displays
}

return 0;
}


Related Solutions

Construct a truth table for the statement [q∨(~r∧p)]→~p. Complete the truth table below by filling in...
Construct a truth table for the statement [q∨(~r∧p)]→~p. Complete the truth table below by filling in the blanks. (T or F) p q r ~r ~r∧p q∨(~r∧p) ~p [q∨(~r∧p)]→~p T T T T T F T F T T F F
Write a truth table for the proposition: ¬(q ∧ r) → (¬p ∨ ¬r). Consider a “1” to be true and a “0” to be false.
Write a truth table for the proposition: ¬(q ∧ r) → (¬p ∨ ¬r). Consider a “1” to be true and a “0” to be false.
Discrete math question Prove that ¬(q→p)∧(p∧q∧s→r)∧p is a contradiction without using truth table
Discrete math question Prove that ¬(q→p)∧(p∧q∧s→r)∧p is a contradiction without using truth table
Prove or disprove using a Truth Table( De Morgan's Law) ¬(p∧q) ≡ ¬p∨¬q
Prove or disprove using a Truth Table( De Morgan's Law) ¬(p∧q) ≡ ¬p∨¬q Show the Truth Table for (p∨r) (r→¬q)
Using a truth table determine whether the argument form is valid or invalid p ∧ q...
Using a truth table determine whether the argument form is valid or invalid p ∧ q →∼ r p∨∼q ∼q→p ∴∼ r
Q2) (a) construct a truth table for the following function: ?(?, ?, ?) = (?? +...
Q2) (a) construct a truth table for the following function: ?(?, ?, ?) = (?? + ?̅?) ̅̅̅ + ?? (b) Use the truth table of (a) to write the function F in sum of minterms form. (c) Expand the function ?(?, ?, ?) = ? + ?̅? to product of Maxterms form. (d) Simplify the following function using K-Map. ?(?, , ?, ?, ?) = ?̅? + ?? + ?̅? + ??̅?
Show that if P;Q are projections such that R(P) = R(Q) and N(P) = N(Q), then...
Show that if P;Q are projections such that R(P) = R(Q) and N(P) = N(Q), then P = Q.
Write C program for RSA encryption and decryptin, where: p = 11,q = 5, e =...
Write C program for RSA encryption and decryptin, where: p = 11,q = 5, e = 7
1. write a truth table using this symbol: --> 2. write the inputs for the truth...
1. write a truth table using this symbol: --> 2. write the inputs for the truth table to the left of the --> and write the outputs for the truth table to the right of the --> 3. write the compliment, or NOT using ' As an example: The truth table for AND is written this way: A B --> A AND B 0 0 --> 0 0 1 --> 0 1 0 --> 0 1 1 --> 1 or...
Prove p → (q ∨ r), q → s, r → s ⊢ p → s
Prove p → (q ∨ r), q → s, r → s ⊢ p → s
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT