Question

In: Computer Science

Part 1 Write a C++ program in which you define the following logical functions: 1) contradictory...

Part 1 Write a C++ program in which you define the following logical functions:

1) contradictory function (¬?)

2) logical and (? ∧ ?)

3) logical inclusive or (? ∨ ?)

4) implication function (? → ?)

5) biconditional (? ↔ ?)

6) logical exclusive or (? ⨁ ?)

You can find the logical definitions for the above functions as given by Bertrand Russell in your text. You need to write a method (function) for each corresponding logical function. The input and output values for each of these functions should be type boolean. Here are the prototypes:

For each of the following propositions, notice the variables are to be assigned some truth values. Using your functions from part 1, evaluate the truth or falsity of the proposition under the specified assignment. Do this in the same source file as for part 1.

Proposition 1: (? → ?) ∧ (¬? → ?) with c and b are F, a is T.

Proposition 2: (? → ?) ∨ (? ↔ ¬(¬? ⨁ ¬?)) with p is T, q and r are F.

Solutions

Expert Solution

#include<iostream>

using namespace logicaloperators;

//function declaration

void contradictory(bool a,bool b);

void logicalAnd(bool a,bool b);

void logicalInclusiveOr(bool a,bool b);

void implication(bool a,bool b);

void biconditional(bool a,bool b);

void logicalExclusiveOr(bool a,bool b);

int main()

{

bool a=true;

bool b=false;

contradictory(a,b);

logicalInclusiveOr(a,b);

logicalAnd(a,b);

implication(a,b);

biconditional(a,b);

logicalExclusiveOr(a,b);

}

void contradictory(bool a,bool b)

{

cout<<"contradictory a is:"<<¬a<<endl;

cout<<"contradictory b is:"<<¬b<<endl;

}

void logicalInclusiveOr(bool a,bool b)

{

cout<<"Logical inclusive OR is:"<<a^b<<endl;

}

void logicalAnd(bool a,bool b)

{

cout<<"Logical AND is:"<<a^b<<endl;

}

void implication(bool a,bool b

{

cout<<"contradictory a is:"<<a→b<<endl;

};

void biconditional(bool a,bool b)

{

cout<<"contradictory a is:"<<a↔b<<endl;

}

void logicalExclusiveOr(bool a,bool b)

{

cout<<"contradictory a is:"<<a⊕b<<endl;

}


Related Solutions

C++ Write a program that produces the truth table of the following logical operators. You aresupposed...
C++ Write a program that produces the truth table of the following logical operators. You aresupposed to output one table with all the operators (one column for each operator). Write theheader of the table - this is the name of the columns-. Output the result on the file prog1 output.txt. The table should contain the letters T and F, it should NOT print 1s and 0s. Show theresults on the following order: 1. negation (!) 2. disjunction (AND operator, &)...
Write a C program that does the following In this part, you will write more complicated...
Write a C program that does the following In this part, you will write more complicated functions. They will require parameters and return values. The purpose is to give you experience with these components, and to show you how functions can be used to break your code down into smaller parts. You will also get some more experience with iterating through arrays.Open repl project Lab: User-Defined Functions 2. Write a program that does the following: 1.(20 pts.) Allows the user...
Program must be in C++! Write a program which: Write a program which uses the following...
Program must be in C++! Write a program which: Write a program which uses the following arrays: empID: An array of 7 integers to hold employee identification numbers. The array should be initialized with the following values: 1, 2, 3, 4, 5, 6, 7. Hours: an array of seven integers to hold the number of hours worked by each employee. payRate: an array of seven doubles to hold each employee’s hourly pay rate. Wages: an array of seven doubles to...
In C++ Prototype your functions above "main" and define them below "main"; Write a program that...
In C++ Prototype your functions above "main" and define them below "main"; Write a program that uses two identical arrays of at least 20 integers. It should call a function that uses the bubble sort algorithm to sort one of the arrays in ascending order. The function should keep count of the number of exchanges it makes. The program then should call a function that uses the selection sort algorithm to sort the other arrays. It should also keep count...
In C++ prototype functions above "main" and define them below "main"; Write a program that uses...
In C++ prototype functions above "main" and define them below "main"; Write a program that uses two identical arrays of at least 20 integers. It should call a function that uses the bubble sort algorithm to sort one of the arrays in ascending order. The function should keep count of the number of exchanges it makes. The program then should call a function that uses the selection sort algorithm to sort the other arrays. It should also keep count of...
Programming assignment 4 : C++ Write a program to do the following: 1.Define a structure to...
Programming assignment 4 : C++ Write a program to do the following: 1.Define a structure to store a date, which includes day(int), month(int), and year(int). 2.Define a structure to store an address, which includes address(house number and street)(string), city(string), state(string), zip code (string). 3.Define a class to store the following information about a student. It should include private member variables: name(string), ID (int), date of birth (the first structure), address (the second structure), total credit earned (int), and GPA (double)....
You are to write a C++ program which does the following: Reads in the size of...
You are to write a C++ program which does the following: Reads in the size of a list of characters. Reads in the list of characters. Prints the list of characters in the opposite order read in. Prints the list of characters in the order read in. Sorts the list. Prints the sorted list. You may assume there will be no more than 1000 characters in the list. (You should use a constant to make this limit easily changeable.) You...
Write a program in C++ to implement Lamport’s logical clocks. Your program should take as input...
Write a program in C++ to implement Lamport’s logical clocks. Your program should take as input a description of several process schedules (i.e., lists of send, receive or print operations). The output of your program will be a linearization of these events in the order actually performed, annotated with Lamport clock values. The input of the program will be a collection of processes, each with a list of operations to perform. The processes are named p1...pn for some n (you...
*****For C++ Program***** Overview For this assignment, write a program that uses functions to simulate a...
*****For C++ Program***** Overview For this assignment, write a program that uses functions to simulate a game of Craps. Craps is a game of chance where a player (the shooter) will roll 2 six-sided dice. The sum of the dice will determine whether the player (and anyone that has placed a bet) wins immediately, loses immediately, or if the game continues. If the sum of the first roll of the dice (known as the come-out roll) is equal to 7...
Write a program in c++, with at least four functions, including main, which must do the...
Write a program in c++, with at least four functions, including main, which must do the following: Ask user whether they want to encode or decode a message – if no, then terminate Take the input string from the user, store it in dynamic memory (use new) As appropriate, encode or decode the message using Rot13. Output the encoded/decoded message Delete the input string from dynamic memory (use delete) Input will be a string of no more than 25 characters....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT