Question

In: Computer Science

In c++ use bool functions to create and print a truth table for disconjunction and negation...

In c++ use bool functions to create and print a truth table for disconjunction and negation functionality and use it to print the truth table for equation pv~p.

Solutions

Expert Solution

#include <iostream>
using namespace std;

int disjunction(bool a, bool b)
{

//This function returns the value of a∨b
if(a==true||b==true)
return 1;
else
return 0;

}

int negation(bool a)
{

//This function returns the value of ~a
if(a==true)
return 0;
else
return 1;
}

int main() {
// declare the bool
bool a = true;
bool b= true;

//Print the disjunction function
printf("Disjunction Truth Table");
printf("\n\nA\tB\tO/P");
printf("\n%d\t%d\t%d",a,b,disjunction(a,b));
printf("\n%d\t%d\t%d",a,!b,disjunction(a,!b));
printf("\n%d\t%d\t%d",!a,b,disjunction(!a,b));
printf("\n%d\t%d\t%d",!a,!b,disjunction(!a,!b));

//Print the negation function
printf("\n\nNegation Truth Table");
printf("\n\nA\t~A");
printf("\n%d\t%d",a,negation(a));
printf("\n%d\t%d",!a,negation(!a));

//Printing the P ∨ ~P equation
printf("\n\nTruth Table for P ∨ ~P");
printf("\n\nP\t~P\tP∨~P");
printf("\n%d\t%d\t%d",a,negation(a),disjunction(a,negation(a)));
printf("\n%d\t%d\t%d",!a,negation(!a),disjunction(a,negation(!a)));


return 0;
}

--------------------------------------------------------------------------------------------------------------------------------------------------------------------

Snapshot of Output:


Related Solutions

write a program that will print a truth table for p ^ ~q. Using C++ please.
write a program that will print a truth table for p ^ ~q. Using C++ please.
Use Python: # Problem Set 01: - Develop neurons and print truth table of the following...
Use Python: # Problem Set 01: - Develop neurons and print truth table of the following 2-input logic gates: AND, OR, NAND, NOR, XOR, XNOR and 1-input NOT gate (Notice: use Markdown to explain how you developed a neuron, and to insert images showing the truth table of logic gates before coding) # Problem Set 02: - Develop neuron and print truth table of XOR gate using only NAND gates - Develop neuron and print truth table of XOR gate...
Use Python: Develop neurons and print truth table of the following 2-input logic gates: AND, OR,...
Use Python: Develop neurons and print truth table of the following 2-input logic gates: AND, OR, NAND, NOR, XOR, XNOR and 1-input NOT gate (Notice: use Markdown to explain how you developed a neuron, and to insert images showing the truth table of logic gates before coding)
create a table of data for two different linear functions. The table should use the same...
create a table of data for two different linear functions. The table should use the same values of X for both functions. Based on your table will the graph of these two functions intersect explain your answer
create a table of data for two different linear functions. The table should use the same...
create a table of data for two different linear functions. The table should use the same values of X for both functions. Based on your table will the graph of these two functions intersect explain your answer
In C++, please check for memory leaks Recursive Functions Goals Create and use recursive functions In...
In C++, please check for memory leaks Recursive Functions Goals Create and use recursive functions In this lab, we will write a program that uses three recursive functions. Requirements: Important: You must use the array for this lab, no vectors allowed. First Recursive Function Write a function that recursively prints a string in reverse. The function has ONLY one parameter of type string. It prints the reversed character to the screen followed by a newline character. Example: Input of “Hello,...
create a VHDL program for the Truth Table below. Please make sure to create your code...
create a VHDL program for the Truth Table below. Please make sure to create your code for the simplified circuit. A B C Z 0 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1 0
Problem 3: Obtain the truth table for the following functions and express each function in sum...
Problem 3: Obtain the truth table for the following functions and express each function in sum of minterms and product of maxterms form: [20 Points] A. X = (B+CD)(C+BD) B. Y = BD’ + ACD’ + AB’C + A’C’ Problem 4: [15 Points] A. Write the following Boolean expression in SOP form : (B+D)(A’+B’+C) B. Write the following Boolean expression in POS form : AB’ + A’C’+ABC
8.   Create a truth table and determine the results for the following equation and values Equation :...
8.   Create a truth table and determine the results for the following equation and values Equation : bool b = ((a+4< 7) || ((b-a > 10) && !(c*a == 8))) Values :   a = 2; b = 8; c = 4 9. Write a program using Atom and submit via Blackboard. a. Request an integer whole dollar amount from the console. b. Using the least amount of bills ($50,$20,$10,$5,$1) necessary, calculate how many of each bill type you will need to get...
Create two arguments, one valid and one invalid. Demonstrate with a truth table the validity of...
Create two arguments, one valid and one invalid. Demonstrate with a truth table the validity of each
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT