Question

In: Computer Science

Write in C++ and insert comments. Input two values a and b 0 may be used...

Write in C++ and insert comments.

Input two values a and b

0 may be used for False

1 may be used for True

Write a program that will print the truth table for the logical operator and give the results for the specific input a, b. The following logical operators should be coded.

● conjunction (AND)

● disjunction (OR)

● conditional Statement (If a then b)

● exclusive OR (XOR)

● biconditional operation (p iff q)

Example for conjunction If the specific input is a=0, b=1, the output for a conjunction should look something like

Truth Table

For a logical conjunction

0 0 0

0 1 0

1 0 0

1 1 1

For the specific values a=1, b=1 the conjunction is true.

(Provide two output one for a,b true and one for a,b false)

Solutions

Expert Solution

#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
        int a,b,temp,i;
        cout<<"\tA B Conj Disj Xor \tBicon \t\t Cond"<<endl;
        for(i=0;i<4;i++){
                temp=i;
                a=i%2;
                temp/=2;
                b=temp%2;
                int c=a&&b;
                int d=a||b;
                int e=a^b;
                cout<<endl<<"\t"<<b<<" "<<a<<" "<<c<<" "<<d<<" "<<e;
                if(a==b){
                        cout<<"\t\t"<<"2";
                }
                else
                        cout<<"\t\t"<<"1";
                if(a==b){
                        cout<<"\t\t"<<"2";
                }
                else{
                        if(a==1 && b==0){
                                cout<<"\t\t"<<"1";
                        }
                        else{
                                cout<<"\t\t"<<"2";
                        }
                }
        }
        
}

Related Solutions

Write the C code required to configure pin 0 on port B to be an input...
Write the C code required to configure pin 0 on port B to be an input with the pullup resistor enabled.
• Write a C++ program that asks the user to input two integer values, then calls...
• Write a C++ program that asks the user to input two integer values, then calls a void function "swap" to swap the values for the first and second variable. • As we mentioned before, in order to swap the valors of two variables, one can use the following: temp= variable1; variable1 = variable2; variable2 = temp; • Display the two variables before you call swap and after you call that function. Comment in code would be greatly appreciated to...
Write a C++ code to insert the following numbers in two Linked Lists. Insert numbers of...
Write a C++ code to insert the following numbers in two Linked Lists. Insert numbers of first list in Linked List#1, and numbers of second list in Linked List#2. Do not insert both lists in a single Linked List. List#1. 5, 78, 45, 23, 11, 89, 10, 78, 6, 99, 876, 5, 67, 13 List#2. 5, 89, 688, 52, 557, 953, 5, 7, 55, 35, 89, 99, 99, 6, 557, 89, 5, 99, 6, 2, 45, 12, 7, 6, 94,...
Write a C++ program that takes two sets ’A’ and ’B’ as input read from the...
Write a C++ program that takes two sets ’A’ and ’B’ as input read from the file prog1 input.txt. The first line of the file corresponds to the set ’A’ and the second line is the set ’B’. Every element of each set is a character, and the characters are separated by space. Implement algorithms for the following operations on the sets. Each of these algorithms must be in separate methods or subroutines. The output should be written in the...
Write a C++ program that takes two sets ’A’ and ’B’ as input read from the...
Write a C++ program that takes two sets ’A’ and ’B’ as input read from the file prog1 input.txt. The first line of the file corresponds to the set ’A’ and the second line is the set ’B’. Every element of each set is a character, and the characters are separated by space. Implement algorithms for the following operations on the sets. Each of these algorithms must be in separate methods or subroutines. The output should be written in the...
write a program that takes two input values from the user and calculate the division if...
write a program that takes two input values from the user and calculate the division if the first number is greater than the second one otherwise calculate the multiplication.
Write a program in Java that will take as input two sets A and B, and...
Write a program in Java that will take as input two sets A and B, and returns a list of all functions from A to B.
Suppose that the double variables a, b and c contain the values -10, 0 1 and2...
Suppose that the double variables a, b and c contain the values -10, 0 1 and2 1 respectively, and the boolean variables b1, b2 and b3 contain the values true, false and false respectively Is each of the following expressions legal or illegal and what will the result be? a) a> b || b>c b) b1 | | b2 && b3
Write short notes on the following (a) Floating input   (b) setpoint    (c) CMRR
Write short notes on the following (a) Floating input   (b) setpoint    (c) CMRR
Discuss the influence of: (a) the two mean values; (b) the two standard deviations; and (c)...
Discuss the influence of: (a) the two mean values; (b) the two standard deviations; and (c) the number of data points for each data set in the statistical analysis that seeks to determine if two mean values from two different populations are statistically equivalent (or not). Assume the same level of significance (p = 0.05) for your discussion.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT