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!
In Visual Studio, create a program that provides the following items: 1 Textbox control 2 Picturebox...
In Visual Studio, create a program that provides the following items: 1 Textbox control 2 Picturebox control 3 int datatype 4 double datatype 5 strings 6 comment each line of code that you put into the form1.cs 7 label control 8 button control The program can be about anything you want. It should be a functional program. Program Items worth (40pts (5pts per item) ) Creativity of your program worth (30pts) Functionality worth (30pts) Submit your (form cs file) and...
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...
You are asked to develop a React App as follow: 1) Create a new component, name...
You are asked to develop a React App as follow: 1) Create a new component, name it YournameComp to the program which extract the Weather info from Weather API (Open Weather Map), and display the current temperature. Upon calling the component, a webform appears which asks user to enter a city name and select the country code (from a drop-down list) and when the user hits the show temperature button, the data will be displayed. 2) Add a Route to...
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 an approximately equal number of loop iterations. The only OpenMP directive you are allowed to use is:...