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...
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...
(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...
----- 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 the Assembly Code for PIC16F84A microcontroller to read a switch connected to Bit 2 of...
Write the Assembly Code for PIC16F84A microcontroller to read a switch connected to Bit 2 of PORTB. You will need to first set the pin to an input, then test whether the pin is 0 ( switch closed, if so go to existing program at label SWITCH If not the program is to continue: Add comments to each line to explain what the code does.
(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...
Can you solve this C program by using Function? Q1. Write a C program to ring...
Can you solve this C program by using Function? Q1. Write a C program to ring the computer bell at any number of times you specify. Use the system clock as a delay, you need to include the time header file.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT