Question

Write a C++ program to verify that the proposition P ∨¬(P ∧Q) is a tautology. If...

Write a C++ program to verify that the proposition P ∨¬(P ∧Q) is a tautology.

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

Thank you so much!

Homework Answers

Answer #1

#include <iostream>

using namespace std;

int main()
{
//boolean variable declaration
bool p,q;

//display table header
cout << "P Q P^Q ~P^Q (p v ~(P^Q)) \n";
  
//display the table data
for ( int i = 0 ; i < 4 ; i++ )
{
p = ( i >> 0 ) & 0x01;
q = ( i >> 1 ) & 0x01;

//display p and q
cout<<p<<" ";
cout<<q<<" ";

cout<<(p&&q)<<" "<<!(p&&q)<<" "<<(p||!(p&&q))<<endl;
}
return 0;
}

OUTPUT:

So, the given expression is a tautology because all output are 1 or true.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Question 1 and 2 requires you to create a program ( you need to submit the...
Question 1 and 2 requires you to create a program ( you need to submit the source code and screenshot for the output), and question 3 and 4 requires solving the problems (no programs needed for those two questions). 1.Write a C++ program to construct the truth table of P ∨¬(Q ∧ R) 2.Write a C++ program to verify that the proposition P ∨¬(P ∧Q) is a tautology.
   Write a C++ program to generate all the truth tables needed for ( p ˄...
   Write a C++ program to generate all the truth tables needed for ( p ˄ q) ˅ (¬ p ˅ ( p ˄ ¬ q )). You need to submit your source code and a screen shot for the output
Write a C++ program to construct the truth table of P || !(Q && R)
Write a C++ program to construct the truth table of P || !(Q && R)
Write a C++ program that processes orders for our company Widgets and More. Your program will...
Write a C++ program that processes orders for our company Widgets and More. Your program will read the product code and quantity for all the products in an order from a file, order.txt. You will be given a sample order.txt with the starter code. There are two items on each line of the file the first is a letter that represents the product and the second is an integer representing the number bought. Based on the product and quantity, you...
Write a C++ Program Consider the following incomplete C++ program: #include <iostream> using namespace std; int...
Write a C++ Program Consider the following incomplete C++ program: #include <iostream> using namespace std; int main() {    …. } Rewrite the program include the following statements. Include the header file fstream, string, and iomanip in this program. Declare inFile to be an ifstream variable and outFile to be an ofstream variable. The program will read data from the file inData.txt and write output to the file outData.txt. Include statements to open both of these files, associate inFile with...
(1) Determine whether the propositions p → (q ∨ ¬r) and (p ∧ ¬q) → ¬r...
(1) Determine whether the propositions p → (q ∨ ¬r) and (p ∧ ¬q) → ¬r are logically equivalent using either a truth table or laws of logic. (2) Let A, B and C be sets. If a is the proposition “x ∈ A”, b is the proposition “x ∈ B” and c is the proposition “x ∈ C”, write down a proposition involving a, b and c that is logically equivalentto“x∈A∪(B−C)”. (3) Consider the statement ∀x∃y¬P(x,y). Write down a...
Please provide answer in the format that I provided, thank you Write a program that prompts...
Please provide answer in the format that I provided, thank you Write a program that prompts the user to input a string. The program then uses the function substr to remove all the vowels from the string. For example, if str=”There”, then after removing all the vowels, str=”Thr”. After removing all the vowels, output the string. Your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel. You must...
----- It's Discrete Mathematics 1.Write each set using set-builder notation. a) C = {...,1/ 27, 1/9,...
----- It's Discrete Mathematics 1.Write each set using set-builder notation. a) C = {...,1/ 27, 1/9, 1/3,1,3,9,27,....} 2.  Verify the following De Morgan’s Law: ¬(P ∧Q) ≡ (¬P)∨(¬Q). 3.  Let P and Q be statements. Show that [(P ∨Q)∧¬(P ∧Q)] ≡ ¬(P ↔ Q). 4.  For statements P, Q, and R, show that ((P → Q)∧(Q → R)) → (P → R) is a tautology.
Write a complete Java program which prompts the user of the program to input his/her first...
Write a complete Java program which prompts the user of the program to input his/her first name, then prompts the user for the middle initial and finally prompts the user for the last name. As indicated, there are three prompts to the user. The program should output the user’s name with the first name first, followed by the middle initial, and the last name last, all on one line (with appropriate spacing). If you could also pinpoint exactly where to...
(complexity theory): let language C be: C = {<p,n> | p and n are natural numbers...
(complexity theory): let language C be: C = {<p,n> | p and n are natural numbers and there is no prime number in the range [p,p+n]} a)explain if the given explanation is good, or if it is bad, explain why: a professor wanted to prove that language C belongs to class NP like this: "for each word <p,n> that belongs to C, there is a confirmation that proves its belonging to the language: the confirmation is formulated by a non...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT