Question

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.

Homework Answers

Answer #1

Question 1:

Answer:

#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:

Question 2:

A given boolean expression is a tautology if it is always true and doesn't depend upon the input.

The given boolean expression is:

P v ~(P^Q)

The above proposition is a tautology if the above proposition is true for all types of input values of P and Q.

The program source code to prove the tautology is given below:

#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:

The given proposition is a tautology because it result true always.

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
   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 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!
Write a program that takes a string of characters (including spaces) as input, computes the frequency...
Write a program that takes a string of characters (including spaces) as input, computes the frequency of each character, sorts them by frequency, and outputs the Huffman code for each character.   When you are writing your program, you should first test it on a string of 7 characters, so you can check it. PLEASE NOTE: Your program must work for any text that has upper and lower case letters digits 0 - 9, commas, periods, and spaces. Please submit the...
Assignment Content You recently graduated from college and are applying for a programming job that requires...
Assignment Content You recently graduated from college and are applying for a programming job that requires the understanding of loops in Python. The manager you are interviewing with has asked you to take an assessment to prove your programming knowledge. Below are the requirements for the programming skills test. In Python, create a program that meets the following requirements: Take two integers from the user. Save the lower number as x. Save the largest integer as y. Write a loop...
In C programming, Thank you Write a program to compute the area of a circle. You...
In C programming, Thank you Write a program to compute the area of a circle. You have to write a complete “C” program that compiles and runs in Codeblocks. Program requirements: 1. Declare the variables needed: radius (r) and area (yourLastName). 2. Calculate and print the area of each circle. 3. The program MUST prompt the user for a new radius (r) over and over until the user types -1. 5. Use the type double for all decimal numbers. 6....
C++ PROGRAMMING Submit the code for each problem separately. Important: Please place all appropriate coding comments...
C++ PROGRAMMING Submit the code for each problem separately. Important: Please place all appropriate coding comments inside of the code. Problem 1    Create a simple linked list program to create a class list containing class node {             void *info;              node *next; public:              node (void *v) {info = v; next = 0; }              void put_next (node *n) {next = n;}              node *get_next ( ) {return next;}              void *get_info (...
1. Please use only the C as the language of programming. 2. Please submit/upload on Canvas,...
1. Please use only the C as the language of programming. 2. Please submit/upload on Canvas, the following les for each of your programs: (1) the client and the server source les each (2) the client and the serve executable les each (3) a brief Readme le that shows the usage of the program. 3. Please appropriately comment your program and name all the identiers suitable, to enable enhanced readability of the code. Problems 1. Write an ftp client that...
SITUATION : Assume that you have to write a program to provide solution to problem face...
SITUATION : Assume that you have to write a program to provide solution to problem face by the company of ABC. The company is providing a service of renting a venue and place such as futsal court, badminton court booking and etc. There are several problems which face by the company in which they have to do it manually. One of the problems maybe during booking of venue. Another problem maybe face by the employee is to reserve the place...
For this assignment you need to write a parallel program in C++ using OpenMP for vector...
For this assignment you need to write a parallel program in C++ using OpenMP for vector addition. Assume A, B, C are three vectors of equal length. The program will add the corresponding elements of vectors A and B and will store the sum in the corresponding elements in vector C (in other words C[i] = A[i] + B[i]). Every thread should execute approximately equal number of loop iterations. The only OpenMP directive you are allowed to use is: #pragma...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in Lab 2 to obtain a diameter value from the user and compute the volume of a sphere (we assumed that to be the shape of a balloon) in a new program, and implement the following restriction on the user’s input: the user should enter a value for the diameter which is at least 8 inches but not larger than 60 inches. Using an if-else...